402 CHAPTER 13 CASE STUDY: USING PHP (Apache web server for windows)
402 CHAPTER 13 CASE STUDY: USING PHP FOR AN XML APPLICATION The page then repeats the process for continents: else if (isset($continent)) { $sql = ‘SELECT * from continent WHERE continentID =’ . $continent; $tres = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($tres) == 0) { $current = $xml->createElement(’current’, ‘Error’); $current = $root->appendChild($current); $error = $xml->createElement(’error’, ‘You appear to have selected . an invalid continent’); $error = $root->appendChild($error); } else { $trow = mysql_fetch_array($tres); $continent_name = $trow[’continent’]; $sql = ‘SELECT * FROM country WHERE countryContinentID =’ . $continent . . ‘ ORDER BY country’; $cres = mysql_query($sql) or die(mysql_error()); $current = $xml->createElement(’current’, $continent_name); $current->setAttribute(’type’, ‘continent’); $current->setAttribute(’id’, $continent); $root->appendChild($current); $items = $xml->createElement(’items’); $root->appendChild($items); $linksto = $xml->createElement(’linksto’, ‘country’); $items->appendChild($linksto); while ($crow = mysql_fetch_array($cres)) { $entry = $xml->createElement(’entry’, $crow[’country’]); $entry->setAttribute(’id’, $crow[’countryID’]); $items->appendChild($entry); } } } If none of the variables has been set, users are at the top level of navigation, and the application must display a list of continents from the database: else { $sql = ‘SELECT * FROM continent ORDER BY continent’; $cres = mysql_query($sql) or die(mysql_error()); $current = $xml->createElement(’current’, ‘Home’); $current->setAttribute(’type’, ‘home’); $root->appendChild($current); $items = $xml->createElement(’items’); $root->appendChild($items); $linksto = $xml->createElement(’linksto’, ‘continent’); $items->appendChild($linksto); while ($crow = mysql_fetch_array($cres)) {
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.