Hello guys,
I am trying to make a very simple booking system. The booking will be either for the current or the next year only. There are three fields; number of person, type of meal and date. In any particualr day and meal, the number of person can't exceed 100. When the user enters a date, number of people and meal type, the bookingcheck script should check if the booking is available. If it is available; it will allow the user to make a booking for that day and meal type. If there was no booking placed on that day, the script should insert the booking details. My problem is in the logic details, I am being unable to lay out the logic for this. If anyone could clarify, I would be grateful. Thank you.
6pand21
<?php
$a = mysql_real_escape_string ($_POST['guest_number']);
$b = mysql_real_escape_string ($_POST['date']);
$c = mysql_real_escape_string ($_POST['food_type']);
$exploded = explode("/", $b);
$d = $exploded[0];
$e = $exploded[1];
$f = $exploded[2];
$year= date ("Y");
$nextyear= $year + 1;
if (($f != $year) and ($f != $nextyear))
{
echo"cannot book for this year";
}
else
{
$result=mysql_query("SELECT * FROM booking WHERE year ='$f' AND food_type ='$c'");
while ($row= mysql_fetch_array($result))
{
$guest = $row['guest_number'] + $a;
if ($guest > 100)
{
//number of guest error
}
else
{
// continue with the booking
}
}
}
?>