Hello there. Sorry that I don't really know much about drop down button in php. I was assign to do a booking system as my final project but somehow I don't know how to make the button works. It suppost to be like this. The user needs to choose which school he is going to book the locker. And after he has choosen, the numbers of lockers will be listed down and he can choose which one that he wants. But the problem here is, the value from drop down button seems like it can't pass the value from the database. Here is the codes :
<?php
session_start();
$user = $_SESSION["user_id"];
$pass = $_SESSION["password"];
?>
<form name="booking" method="post" action="booking.php">
<table width="213" border="0">
<tr>
<td width="300" height="34">Select School</td>
</tr>
<tr>
<td><select name="school">
<option value="1">SMK Seri Pantai</option>
<option value="2">SMK Tengku Sulaiman</option>
<option value="3">SMK Convent Butterworth</option>
<option value="4">SMK Dato' Megat Khas</option>
</select>
</td>
</tr>
<tr>
<td width="10"> </td>
<td><input name="submit" type="submit" value="Next">
<input name="next" type="hidden" id="next"></td>
</tr>
</table>
</form>
I seperated this to so that it won't confuse me much.
<?php
session_start();
$user = $_SESSION["user_id"];
$pass = $_SESSION["password"];
$conn = mysql_connect("localhost", "root", "") or die ("Could not connect to server");
$db = mysql_select_db("Smartlocker", $conn) or die ("Could not connect to database");
$sql = "SELECT * FROM locker WHERE school='$next' ";
$result = mysql_query($sql) or die ("Could not execute query");
$myrow=mysql_fetch_row($result);
if($myrow=mysql_fetch_row($result))
{
echo "
<table border='1' bordercolor='C0F7FE'>
<tr>
<td><center><strong>School</strong></center></td>
<td><center><strong>Locker No.</strong></center></td>
<td><center><strong>Price (RM)</strong></center></td>
<td><center><strong>Status</strong></center></td>
<td><center><strong>Book</strong></center></td>
</tr>";
do{
echo "
<tr>
<td>$myrow[2]</td>
<td>$myrow[3]</td>
<td>$myrow[5]</td>
<td></td> //I haven't don't this part yet
<td><form name='booked' action='booking-process.php' method='post'>
<input type='submit' name='submit' value='Book'>
<input name='book' type='hidden' id='booked' value='$myrow[0]'> //$myrow[0] is my primary key
</form></td>
</tr>";
}while($myrow=mysql_fetch_row($result));
echo "</table>";
}
?>
I hope someone can help me with this. :(