<?php

//Check for request method
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    assignCar();
} else {
    displayBookings();
}
//This function accesses databases and sends records as XML
function displayBookings()
{
    $host;
    $user;
    $pswd;
    $dbnm;
    $connection = mysqli_connect($host, $user, $pswd, $dbnm) or die('Failed to connect.');
    $searchQuery = "SELECT * FROM bookings where status = 'unassigned'";
    $result = mysqli_query($connection, $searchQuery);
    $xml = new SimpleXMLElement('<xml/>');
    if (mysqli_num_rows($result) > 0) {
        while ($result_array = mysqli_fetch_array($result)) {
            $data = $xml->addChild('search');
            $data->addChild('bookingNumber', $result_array['bookingNumber']);
            $data->addChild('customerName', $result_array['customerName']);
            $data->addChild('pickupAddress', $result_array['pickupAddress']);
            $data->addChild('suburb', $result_array['suburb']);
            $data->addChild('destination', $result_array['destination']);
            $data->addChild('phoneNumber', $result_array['contactPhone']);
            $data->addChild('pickUpDate', $result_array['pickUpDate']);
            $data->addChild('pickUpTime', $result_array['pickUpTime']);
            $data->addChild('bookingDate', $result_array['bookingDate']);
Esempio n. 2
0
<!DOCTYPE html>
<html>
	<head>
		<title>Contacts</title>
	</head>
	<body>

		<div id="main_container">

			<h1 style="text-align:center;"></h1><br />
			<fieldset>
				<legend align="center">Your Bookings!</legend><br/>
			<?php 
include "Functions.php";
print displayBookings($_SESSION['userid']);
?>

			</fieldset>

		</br></br>

			<?php 
include "footer.php";
?>

		</div>

	</body>
</html>