My problem is: every time I click on submit the selection values form the first drop-down clear. But I want the selections to stay, so the user can re-use the form to submit a differnet selection.
Here is the code: The file name is "dd3ck.php"
Code: Select all
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Multiple drop down box</title>
</head>
<body>
<?php
if (!empty($_POST)) {
$username="root";
$password="";
$database="cs631";
// Connect to the server
$con = mysql_connect(localhost,$username,$password);
mysql_select_db($database, $con);
$cat = $_REQUEST['cat'];
$q1 = "SELECT * FROM `Station` WHERE RouteSriNumber = " . $cat;
$result = mysql_query($q1);
?>
<table>
<tr>
<td>
Select a Station ID from the List:
</td>
<form method=post name=f2 action='dd3ck.php'>
<tr><td>
<?php
echo "";
echo "<select size = 5 name='Station'>" ;
while($noticia = mysql_fetch_array($result)) {
echo "<option value='$noticia[StationID]'> $noticia[StationID] </option>";
}
echo "</select>";
}
//mysql_close($con);
?>
</td></tr>
<tr><td> <input type=submit value='Submit'></td></tr>
</form>
</table>
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST"){
$St = $_REQUEST['Station'];
If ($St <>"")
{
$username="root";
$password="";
$database="cs631";
// Connect to the server
$con = mysql_connect(localhost,$username,$password);
mysql_select_db($database, $con);
$q2 = "SELECT * FROM `Station` WHERE RouteSriNumber =" . $St;
echo $q2;
$result2 = mysql_query($q2);
echo "<table border='1'>
<tr>
<th>StationID</th>
<th>Latitude</th>
<th>Longitude</th>
</tr>";
while($row = mysql_fetch_array($result2))
{
echo "<tr>";
echo "<td>" . $row['StationID'] . "</td>";
echo "<td>" . $row['Latitude'] . "</td>";
echo "<td>" . $row['Longitude'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
}
}
?>
</body>
</html>[/color]