Hey again,
I'm back with a new problem that needs to be solved right NOW due to a very tight deadline (Monday).
I'm trying to print theater seats in rows of 5, where the seats that are already taken will be printed as black (i have an image for that). Now I can print properly the seats that have not yet been taken, but when i select one of the seats (they are checkboxes) that are on row 2 or 3, they seem to be forgotten by the script, because they are not printed as black seats. However - and I'm sorry if I'm losing you now - for some reason when I checked seats 1, 6 and 11, seat 1 and 6 showed up as black ones, but not seat 11.
Here's an example of what it looked like when I selected seats 1, 6 and 11:
I hope you've read the text above, if you did, then you'll understand that something's wrong with my script and that I want your help to fix it.
As you will se in the code i have three for's instead of just one, and that is because I used to have only one for-loop, but since that didn't work either I tried using three for-loops instead.
You may view the entire code here:
http://pastebin.com/m1301265a
PHP Code:
<div id="stolar">
<!-- Ladda in bild2 i bakgrunden (Image preloader) -->
<div style="visibility: hidden; height: 0px; width: 0px;"><img src="stoloff.jpg" alt="" /></div>
<?php
// Definiera sql för att kolla om stolen är upptagen
$sqlStolar = "SELECT stolID FROM bokningar WHERE stolID < 6";
$resultStolar = mysql_query($sqlStolar, $connection) or die (mysql_error());
// Definiera sql för att kolla om stolen är upptagen
$sqlStolar2 = "SELECT stolID FROM bokningar WHERE stolID > 5 AND stolID < 11";
$resultStolar2 = mysql_query($sqlStolar2, $connection) or die (mysql_error());
// Definiera sql för att kolla om stolen är upptagen
$sqlStolar3 = "SELECT stolID FROM bokningar WHERE stolID > 10 AND stolID < 16";
$resultStolar3 = mysql_query($sqlStolar3, $connection) or die (mysql_error());
// Print seats, and black seats if seat's taken
for($i=1; $i < 6; $i++) {
$minRad = mysql_fetch_array($resultStolar);
// Print black seat if true
if($minRad['stolID'] == $i) {
echo "<div class=\"disabledBox\">\n</div>\n";
}
// Else; print red ones
else {
echo "<div class=\"pimp_my_box\" id=\"pimp{$i}\" onclick=\"checkIt(this, 'demo{$i}')\">\n\t<input type=\"checkbox\" id=\"demo{$i}\" class=\"demo\" name=\"platser[]\" value=\"{$i}\" />\n</div>\n";
}
}
for($k=6; $k < 11; $k++) {
$raud = mysql_fetch_array($resultStolar2);
if($raud['stolID'] == $k) {
echo "<div class=\"disabledBox\">\n</div>\n";
}
else {
echo "<div class=\"pimp_my_box\" id=\"pimp{$k}\" onclick=\"checkIt(this, 'demo{$k}')\">\n\t<input type=\"checkbox\" id=\"demo{$k}\" class=\"demo\" name=\"platser[]\" value=\"{$k}\" />\n</div>\n";
}
}
for($r=11; $r < 16; $r++) {
$rawd = mysql_fetch_array($resultStolar3);
if($rawd['stolID'] == $i) {
echo "<div class=\"disabledBox\">\n</div>\n";
}
else {
echo "<div class=\"pimp_my_box\" id=\"pimp{$r}\" onclick=\"checkIt(this, 'demo{$r}')\">\n\t<input type=\"checkbox\" id=\"demo{$r}\" class=\"demo\" name=\"platser[]\" value=\"{$r}\" />\n</div>\n";
}
}
?>
</div>
If there's something you don't understand, just ask!
Thank you!