Hello there. This is what I'm trying to do. When user click at the firs drop down button which contain the location of the school, that button will retrieve data from database and it will appear at the same page of the button. The problem that I'm having right now is, how am I suppose to save the value starting from location until payment inside of database. I try to seperate the form but, some data didn't enter the database. When I put it all in the same form, when the confirm button is click, it redirect to the same page and there is no data enteres in the database. This is my code.
<html>
<body>
<?php
session_start();
$user=$_SESSION['user_id'];
?>
<table width="1281" height="351" border="1" <form name="book" method="post" >bordercolor="C0F7FE" bgcolor="E9F1EA">
<tr>
<td valign="top" height="175">
Select School<br><br>
<select onChange="submit()" name="school">
<?php
$school = array(' ' => 'SELECT',
'1' => 'SMK Seri Pantai',
'2' => 'SMK Tengku Sulaiman',
'3' => 'SMK Convent Butterworth',
'4' => 'SMK Dato Megat Khas');
foreach($school as $value => $caption)
{
echo "<option value='$value'>$caption</option>";
}
?> </select>
<?php
$next=$_POST['school'];
$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 category_id='$next' ";
$result = mysql_query($sql) or die ("Could not execute query");
?>
<?php
if($myrow=mysql_fetch_row($result))
{
echo "
<table width='600' border='1' bordercolor='C0F7FE'>
<tr><td></td>
<td><center><strong>School</strong></center></td>
<td><center><strong>Locker No.</strong></center></td>
</tr>";
do{
echo "
<tr><td><input type='radio' name='check' value='$myrow[3]'> </td>
<td>$myrow[2]</td>
<td><center>$myrow[3]</center></td>
</tr>";
}
while($myrow=mysql_fetch_row($result));
echo "</table>";
?>
<br>
<table width="270" border="0">
<tr>
<td>Number of day to book : </td>
<td><select>
<?php
for($i=1; $i<=30; $i++)
{
echo "<option value='$i'>$i</option>";
}
?>
</select> day(s)
</td>
</tr>
</table>
<br>
<table width="270" border="0">
<tr>
<td>From</td>
<td><select>
<?php
for($a=01; $a<=31; $a++)
{
echo "<option value='$a'>$a</option>";
}
?>
</select></td>
<td><select>
<?php
$month = array('01' => 'January',
'02' => 'February',
'03' => 'March',
'04' => 'April',
'05' => 'May',
'06' => 'June',
'07' => 'July',
'08' => 'August',
'09' => 'Sepytember',
'10' => 'October',
'11' => 'November',
'12' => 'December');
foreach($month as $value => $bulan)
{
echo "<option value='$value'>$bulan</option>";
}
?>
</select></td>
<td><select>
<?php
for($b=2012; $b<=2050; $b++)
{
echo "<option value='$b'>$b</option>";
}
?>
</select></td>
</tr>
<tr>
<td>To</td>
<td><select>
<?php
for($c=01; $c<=31; $c++)
{
echo "<option value='$c'>$c</option>";
}
?>
</select></td>
<td><select>
<?php
$month2 = array('01' => 'January',
'02' => 'February',
'03' => 'March',
'04' => 'April',
'05' => 'May',
'06' => 'June',
'07' => 'July',
'08' => 'August',
'09' => 'Sepytember',
'10' => 'October',
'11' => 'November',
'12' => 'December');
foreach($month2 as $value2 => $bulan2)
{
echo "<option value='$value2'>$bulan2</option>";
}
?>
</select></td>
<td><select>
<?php
for($d=2012; $d<=2050; $d++)
{
echo "<option value='$d'>$d</option>";
}
?>
</select></td>
</tr>
</table>
<br>
Payment can only be made through :<br>
<input type='radio' name='pay' value='BankDeposit'> Bank Deposit<br>
<table width="600" border="0">
<tr>
<td><div align="right">
<input type='submit' name='submit' value='Confirm'>
</div></td>
</tr>
</table>
<?php } ?>
</td>
</tr>
</table>
</form>
</body>
</html>