add data depending on people selected

im having troube figuring this out :-[

iv got a select menu where the user puts how many people are being booked in

menu where they select the time which they want to book in at,

every person gets booked in for 1 hour

and here is what im trying to do,

if 1 person gets booked in at 9pm

9pm is added to the data base and cant be used again on that date

and if someone books say for example 3 people in (which is 3 hours) at 4pm which will take use to 7pm
how would i add 4 pm, 5pm, 6pm to the database as they are now unavailable

i need to add individual hours

Depends on how the database table is setup for tracking that info. Create another table to hold just that information. Then before you get to the time selector, run a query and compare the taken dates to what’s in your time selector. That way, they can’t book a time that’s already taken.

Yeah i come up with something like this and its where i got stuck

adding the data to the data base where it just errors

[php]$result=mysql_query($sql);

$listhour = $listhour-1;
for($i = 0; $i > $people; $i++)
{
//echo $i+1 . " ";
$listhour = $listhour+1;
$newtimes = $listhour . " " . $listampm;

$sql=“INSERT INTO $tbl_name(dates, times)VALUES(’$compdate’, ‘$newtimes’)”;
if($result){
echo “$newtimes Success!”;
}

else {
echo “$newtimes ERROR”;
}

mysql_close();
}[/php]

help appriciated :open_mouth:

Sponsor our Newsletter | Privacy Policy | Terms of Service