Hi,
I have set up a database as follows: 1 table called screen1 with 2 fields: ID and status
I have code to create a HTML table that checks each status entry for every ID (ID is an auto_increment primary key) and depending on the value of status (whether it is 1 or zero) the code will output some HTML code.
This is for a cinema booking system. I have check boxes so that a user can tick eg: 5 checkboxes and book those 5 seats without having to go back and click a link and book it 1 seat at a time (the way i had it before)
However, I cant get this working properly with the checkboxes.
here is the code I have so far:
PHP:
<head>
<style>
td(font-family:verdana; font-size:10px)
a{color:white; text-decoartion:none; font-family:verdana}
a.hover{color<img src="images/smilies/redface.gif" border="0" alt="">range; text-decoration:underline}
</style>
</head>
<body>
<FORM action="screen1.php?act=1" method="post">
<table width="760" align="center" border="1" cellpadding="5">
<tr>
<td colspan="20">Screen 1</td>
</tr>
<tr>
<?php
// connect things here
mysql_connect("localhost", "root", "");
mysql_select_db("cine") or die(mysql_error());
$query = mysql_query("SELECT id, status FROM screen1") or die(mysql_error());
$i = 0;
while ($data = mysql_fetch_array($query))
{
extract($data);
if ($status == 0)
echo "<td bgcolor='white' width='20'><input type='checkbox' name='$s'></td>";
else
echo "<td bgcolor='orange' width='20'><font size='1' face='verdana'><a href='cancel1.php?id=$id'>cancel</a></font></td>";
$i++;
if ($i % 20 == 0)
echo "</tr><tr>";
}
// echo "$id is available";
?>
<tr>
<td colspan="20" align="right">
<input type="submit" name="submit">
</td>
</tr>
</table>
</form>
</body>
<?php
if($act == 1) {
$i = 0;
while($i < 200) {
//$seat = $s;
//$st = $$seat;
if($s == "on") {
$query = "INSERT INTO bookings (id, status) VALUES ('$i', '1')";
}
else {
$seatstat = 0;
echo "x";
}
$i++;
}
}
?>
Any help on this is appreciated.