I need to create a bus seat booking system. As you can see from the image below, there are 30 seats with 3 column. Currently after clicking the submit button, my code (can see example code below) will display the seat number that they have chosen. But what I want to add is to display the seat type and price, ok for example (from the image):
- Left column type of seat is 'single', middle column is 'aisle', and right column is 'window'.
- 'single' seat is $10 while the others are $5.
So, how do I display the seat number with its type and price in efficient way? (maybe using multidimensional array?). Sorry if my question is not clear enough as I'm still beginner in coding.
bus seat booking system (click here to see the image)
my html (3 seat example):
<li class="seat">
<input type="checkbox" name="seatcheckbox[]" value="1" id="1"/>
<label for="1"></label>
</li>
<li class="seat">
<input type="checkbox" name="seatcheckbox[]" value="2" id="2"/>
<label for="2"></label>
</li>
<li class="seat">
<input type="checkbox" name="seatcheckbox[]" value="3" id="3"/>
<label for="3"></label>
</li>
my php:
if (isset($_POST["submit"]))
{
if(!empty($_POST["seatcheckbox"]))
{
echo 'You have selected the following seats: ';
foreach($_POST["seatcheckbox"] as $seatcheckbox)
{
echo $seatcheckbox . ', ';
}
}
else {
{
echo 'Please select at least 1 seat';
}
}
}