<?php
	require_once ('authorize1.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">

<head>
<title>Moreno Travel</title>
<script src="sorttable.js"></script>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="content-type"
        content="text/html; charset=utf-8" />

<style>

tr.order { border-bottom: 1px solid }</style>

</head>




<?php include 'admin_header.php'; ?>

<h1>Manage hotel to Package Assignments</h1>


<ul>

<i><font color="#C11B17" size="0.5px">Click <a href="admin_addhotel.php" target="blank">here</a> to add a new hotel.<br>
Click <a href="admin_addpackage.php" target="blank">here</a> to add a new package.<br>
Click <a href="admin_addhotelpackagelink.php" target="blank">here</a> to add a new package to hotel assignment.<br><br>
</i></font>
<table><tr><td width="300px"><b>Package</b></td><td width="300px"><b>hotel</b></td></tr>


<?php
require_once('connectvars.php');

$dbh = mysql_connect(hostname, username, password)

	or die("Unable to connect to MySQL");

mysql_select_db (dbname, $dbh);

$result = mysql_query("SELECT * FROM hotelpackagelink cl, hotel c, packages p WHERE cl.hotel_id = c.hotel_id AND cl.package_id = p.package_id");

$i = 0;

print "<form name='managehotelpackage' method='post' action='admin_updatehotelpackagelink.php'>\n";

while ($hotelpackage = mysql_fetch_array($result)) {
//print $hotelpackage['hotel_id'];
//die();
print"<tr><td>"
?>
<select name="package_id[]"  />  <option value="disabled" >Select a Package:</option> 

 <?php

$dbh = mysql_connect(hostname, username, password)

	or die("Unable to connect to MySQL");

mysql_select_db (dbname, $dbh);



$query = sprintf("SELECT package_name, package_id FROM packages ORDER BY package_name ASC");




$resultp = mysql_query($query);


if (!$resultp) {

    $message  = 'Invalid query: ' . mysql_error() . "\n";

    $message .= 'Whole query: ' . $query;

    die($message);

}


while ($row = mysql_fetch_assoc($resultp)) {

if ($row['package_id']==$hotelpackage['package_id']){$selected =  " selected=true ";} else {$selected = "";}
echo "<option value=\"".$row['package_id']. "\"". $selected . ">".$row['package_name']."</option>";

}
?>
</select><br><br>


</td>

<td>
<input type="hidden" name="hotelpkg_id[]" value="<?php echo $hotelpackage['hotelpkg_id'] ?>">
<select name="hotel_id[]"  />  <option value="disabled" >Select a hotel:</option> 

 <?php

$dbh = mysql_connect(hostname, username, password)

	or die("Unable to connect to MySQL");

mysql_select_db (dbname, $dbh);



$query = sprintf("SELECT hotel_name, hotel_id FROM hotel ORDER BY hotel_name ASC");




$resultc = mysql_query($query);


if (!$resultc) {

    $message  = 'Invalid query: ' . mysql_error() . "\n";

    $message .= 'Whole query: ' . $query;

    die($message);

}


while ($row = mysql_fetch_assoc($resultc)) {

if ($row['hotel_id']==$hotelpackage['hotel_id']){$selected =  " selected=true ";} else {$selected = "";}
echo "<option value=\"".$row['hotel_id']. "\"". $selected . ">".$row['hotel_name']."</option>";

}
?>
</select><br><br>

</td></tr>

<?php

++$i;
}
print "<tr><td><input type='submit' value='submit' /></td></tr>";
print "</form>";
mysql_close();
?>



</table>
<br><br>




</ul><br><br><br>
</div>

</div>

</body>

</html>