This is my databasen:
CREATE TABLE `reg` (
`id` int(10) NOT NULL auto_increment,
`color` varchar(255) NOT NULL default '',
`name` varchar(255) NOT NULL default '',
`seat` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
Seat.php:
<?php
include "room.php";
include "config.php";
$id = $_GET['id'];
$hent = mysql_query("SELECT * FROM reg WHERE seat = '$id'");
if (mysql_num_rows($hent) == "0") {
echo ("<br /><a href='velg.php?id=$id'><b>This seat is free.</font><br />
Sit here</a>");
}
while($r=mysql_fetch_array($hent)) {
$seat = $r['seat'];
$name= $r['name'];
echo ("<br /><b>This seat is taken!<br />$name is sitting here.</b>");
}
?>
Room.php :
<table width="400" cellpadding="10" cellspacing="0" id="1" border="1" bordercolor="#000000" rules="all">
<tr>
<td width="16" id=1 class="<?php include("ledig.php?id=1"); ?>"><a href="seat.php?id=1">1</a></td>
<td width="16" id=2 class="<?php include("ledig.php?id=2"); ?>"><a href="seat.php?id=2">2</a></td>
<td width="16" id=3 class="<?php include("ledig.php?id=3"); ?>"><a href="seat.php?id=3">3</a></td>
<td width="16" id=4 class="<?php include("ledig.php?id=4"); ?>"><a href="seat.php?id=4">4</a></td>
<td width="16" id=5 class="<?php include("ledig.php?id=5"); ?>"><a href="seat.php?id=5">5</a></td>
<td width="16" id=6 class="<?php include("ledig.php?id=6"); ?>"><a href="seat.php?id=6">6</a></td>
<td width="16" id=7 class="<?php include("ledig.php"); ?>"><a href="seat.php?id=7">7</a></td>
<td width="16" id=8 class="<?php include("ledig.php"); ?>"><a href="seat.php?id=8">8</a></td>
<td width="16" id=9 class="<?php include("ledig.php"); ?>"><a href="seat.php?id=9">9</a></td>
<td width="16" id=10 class="<?php include("ledig.php"); ?>"><a href="seat.php?id=10">10</a></td>
</tr>
</table>
Velg.php: (or in english pick.php)
<?php
include("config.php");
if ($_POST[register]) {
$seat = $_POST[seat];
$name = $_POST[name];
$color = $_POST[color];
if($seat==NULL|$name==NULL|$color==NULL) {
echo "You forgot somethinge.";
} else {
$checkid = mysql_query("SELECT seat FROM reg WHERE seat='$seat'");
$checkid= mysql_num_rows($checkid);
if ($checkid>0) {
echo "This seat is taken!";
} else {
$checkname = mysql_query("SELECT name FROM reg WHERE name='$name'");
$checkname= mysql_num_rows($checkname);
if ($checkname>0) {
echo "Your name is already registered!";
} else {
$seat = htmlspecialchars($seat);
$name = htmlspecialchars($name);
$color = htmlspecialchars($color);
$query = mysql_query("INSERT INTO reg (seat, name, color) VALUES('$seat','$name','$color')");
echo "Your seat is reserved.";
}
}
}
} else {
$id = $_GET['id'];
echo (" <form method='POST'>
Is this correct?<br />
Seat: <input type='text' size='30' name='seat' value='$id'><br />
Name: <input type='text' size='30' name='name'><br />
<input type='hidden' name='color' value='taken'>
<input name='register' type='submit' class='text' value='Submit'>
</form>");
}
?>
Edited by Zetra, 02 July 2007 - 06:01 PM.