Hey all,
Newby problem of the day:
I would like to give the user of my interface the possibility to select two cities from a database to enable him/her to calculate the distance between both.
However, I would like the cities to be selected in two steps. First, "select the country" and then "select the city within the choosen country". My SQL database is made and now I would like to optimize the interface. First I thought about using a rolling menu, but now I'm not so sure it is the way to go.
This is how it looks so far:
<html>
<head><title>Definition of the trip</title></head>
<body>
<ul>
<?
mysql_connect("localhost", "username", "pasword");
mysql_selectdb("cities");
$listofairports = mysql_query("SELECT name, latitude, longitude FROM cities");
$row = mysql_fetch_array($listofcities);
while ($row) {
echo ("<li>" . $row['name'] . ", " . $row['latitude'] . ", " . $row['longitude'] . "</li>");
$row = mysql_fetch_array($listofcities);
}
?>
</ul>
<?
mysql_close();
?>
<form method="post" action="definevehicle.php">
<table width="650">
<tr>
<td width="250">Please select the city of departure:</td>
<td><select name="departure" size="1">
<option value="london"> London
<option value="paris"> Paris
<option value="madrid"> Madrid
</select><br></td>
<br>
</tr>
</table>
</form>
The output gives a list of the cities, followed by a roll-down menu including London, Paris and Madrid. But
My problem is that I have no clue on how to enable the user to select a city in the database without having to inserting them one by one in the form.
I mean how can I automatically include all of the cities of the database in the menu?
Anyone having a suggestion? Thanks a lot in any case!
Cheers!