maybe this help:
index.php
<?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>
2.booking.php
session_start();
$user = $_SESSION["user_id"];
$pass = $_SESSION["password"];
<?php
require_once("../includes/config.php");
require_once("../includes/dbconnect.php");
if (isset($_POST['submit'])) {
$school = $_POST['school'];
$sql = mysql_query("SELECT * FROM locker WHERE school_id = '$school'") or die(mysql_error());
?>
<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>
<?php
if (mysql_num_rows($sql) > 0) {
while ($row = mysql_fetch_array($sql)) {
$looker_id = $row['id'];
$name = $row['name'];
?>
<tr>
<td><?= $school ?> //school id, related from database</td>
<td><?= $name ?></td>
<td>// Price</td>
<td>// Status</td>
<td>
<form action='booking-process.php' method='post'>
<input type='submit' name='submit' value='Book'>
<input name='book' type='hidden' value='<?= $looker_id ?>'>
</form>
</td>
</tr>
<?php
}
} else {
?>
<tr><td colspan="5">No data</td></tr>
<?php
}
?>
</table>
<?php
}
else{
echo "No data";
}
?>
dean8710
Junior Poster in Training
66 posts since Jul 2011
Reputation Points: 7
Solved Threads: 3
Skill Endorsements: 0
sorry but I don't get what does require_once("../includes/config.php");and require_once("../includes/dbconnect.php"); does. before what I learn is really basic. What is requires inside this includes?
to answer your question require_once is just the info of your database and server connection which is in your code the $conn = mysql_connect("localhost", "root", "") or die ("Could not connect to server"); and $db = mysql_select_db("Smartlocker", $conn) or die ("Could not connect to database"); part
ehpratah
Junior Poster in Training
82 posts since May 2012
Reputation Points: 13
Solved Threads: 1
Skill Endorsements: 0
Question Answered as of 4 Months Ago by
code739,
baig772,
dean8710
and 1 other