<?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'; ?>

<div id="main2">
<h1>Moreno Travel Admin Portal</h1>


<ul>



<p>Manage cities as required:</p>

<table><tr><td width="70px"><b>City ID</b></td><td width="300px"><b>City</b></td><td width="300px"><b>State</b></td><td width="300px"><b>Picture</b></td></tr></table>

<?php

function location_dropdown($location_id,$i)
{

	$query = sprintf("SELECT * FROM location ");
//$i = 0;



	$result = mysql_query($query);


	if (!$result) {

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

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

    	die($message);

	}


echo "<select name='location_id[$i]'>";
while ($row = mysql_fetch_assoc($result)) {
	
		echo "\n<option value='" .$row['location_id'] . "'";
		if ($row['location_id']==$location_id) echo " selected "; 
		echo " >" . $row['location_name'] . "</option>" ;

	}	
echo "</select>";

}

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 cities ORDER BY city_name");

$i = 0;

echo "<form name='managecities' method='post' action='admin_updatecities.php'>\n";

while ($cities = mysql_fetch_array($result)) {

echo "<input type='text' size='3' name='city_id[$i]' value='{$cities['city_id']}' />";
echo "<input type='text' size='30' name='city_name[$i]' value='{$cities['city_name']}' /> 
<input type='text' size='30' name='city_state[$i]' value='{$cities['city_state']}' />";?>

<?php
	//echo "i=" . $i;	
   
	location_dropdown($cities['location_id'],$i);

?>

<?echo "<input type='text' size='30' name='city_pic[$i]' value='{$cities['city_pic']}' /><br>
<textarea cols='110' rows='10' name='city_details[$i]'>{$cities['city_details']}</textarea><hr>";

	$i++;
//echo "i=" . $i;

}
echo "<br><input type='submit' value='submit' />";
echo "</form>";
mysql_close();
?>



<br><br>




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

<?php include 'footer.php'; ?>
</div>

</body>

</html>