<?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 Attraction to Package Assignments</h1>


<ul>


<i><font color="#C11B17" size="0.5px">Click <a href="admin_addinfo.php" target="blank">here</a> to add a new attraction.<br>
Click <a href="admin_addpackage.php" target="blank">here</a> to add a new package.<br>
Click <a href="admin_addinfopackagelink.php" target="blank">here</a> to add a new package to attraction assignment.<br><br>
</i></font>
<table><tr><td width="300px"><b>Package</b></td><td width="300px"><b>Attraction</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 infopackagelink cl, info c, packages p WHERE cl.info_id = c.info_id AND cl.package_id = p.package_id ORDER BY p.package_name");

$i = 0;

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

while ($infopackage = mysql_fetch_array($result)) {
//print $infopackage['info_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']==$infopackage['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="infopkglink_id[]" value="<?php echo $infopackage['infopkglink_id'] ?>">
<select name="info_id[]"  />  <option value="disabled" >Select an Attraction:</option> 

 <?php

$dbh = mysql_connect(hostname, username, password)

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

mysql_select_db (dbname, $dbh);



$query = sprintf("SELECT info_name, info_id FROM info ORDER BY info_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['info_id']==$infopackage['info_id']){$selected =  " selected=true ";} else {$selected = "";}
echo "<option value=\"".$row['info_id']. "\"". $selected . ">".$row['info_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>