1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| <?php
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
error_reporting(E_ALL);
if(isset($_GET['id']))
{
# Get the ID
$id = $_GET['id'];
# Make sure the ID is in fact a valid ID
if(!is_numeric($id) || ($id <= 0)) {
die("The ID is invalid!");
}
include_once 'connect.php';
mysql_select_db($dbname, $conn);
$sql = "SELECT DISTINCT .....' ORDER BY .....";
$qry = mysql_query($sql) or die(mysql_error());
$xml = new DOMDocument('1.0', 'UTF-8');
$message = $xml->createElementNS(NULL, 'message');
$message->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$message->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:xsd','http://www.w3.org/2001/XMLSchema');
$xml->appendChild($message);
if (mysql_num_rows($qry))
{
$rooms= $xml->createElement('rooms');
$rooms = $message->appendChild($rooms);
while ($data = mysql_fetch_assoc($qry)) {
if (!isset($room) || $data['room_uid'] != $room->getAttribute('code')) {
$room = $xml->createElement('room');
$room = $rooms->appendChild($room);
$room->setAttribute("code",$data['room_uid']);
$room->setAttribute("name", $data['room_name']);
$room->setAttribute("maxOccupancy", $data['maxpeople']);
$room->setAttribute("minOccupancy", $data['minpeople']);
$rooms->appendChild($room);
}
$rate = $xml->createElement('rate');
$rate = $room->appendChild($rate);
$rate->setAttribute("code",$data['rates_uid']);
$rate->setAttribute("name", $data['rate_title']);
$rate->setAttribute("regime", $data['room_class_abbv']);
}
// $xml->appendChild($rooms);
$xml->appendChild($message);
}
header('Content-type: text/xml');
mysql_set_charset('utf8');
//header('Content-type: text/plain');
header('Charset: utf-8');
echo htmlentities($xml->saveXML());
//echo $xml->saveXML();
}
else
{
echo "Error! No ID was passed.";
}
?> |
Partager