Hi,
I have a problem trying to prevent a time slot and seat number being double booked. I am using PHP and MySQL for this. Currently I have no errors concerning variable names or issues with inserting data into the database. The only problem I seem to have involves preventing a certain seat number and time from being double booked. I have tried numerous things and I think the problem lies within my 'if' statement so i have shown a snippet of this below:
Like I said all my variable names and SQL commands are working and the data is being inserted into the correct database tables and fields. The only problem is preventing the time and seat number from being double booked. I am a noob when it comes to PHP and MySQL so any feedback is much appreciated.
Thanks,
Jordan
I have a problem trying to prevent a time slot and seat number being double booked. I am using PHP and MySQL for this. Currently I have no errors concerning variable names or issues with inserting data into the database. The only problem I seem to have involves preventing a certain seat number and time from being double booked. I have tried numerous things and I think the problem lies within my 'if' statement so i have shown a snippet of this below:
Code:
$sql="SELECT * FROM swinging_ship WHERE Time='$time' AND SeatNumber='$seatnumber'";
$sqlresult=mysql_query($sql) or die("Could not retreive data from table");
$row=mysql_fetch_array($sqlresult);
if ($row['Time']=='$time' AND $row['SeatNumber']=='$seatnumber')
{
echo "<br />Please Go back this seat is taken\n";
}
else
{ $sqlstatement="INSERT INTO customer_details (Title, FirstName, MiddleName, LastName, HouseNoName, Address, Town, County, Postcode, TelephoneNumber, Email)
VALUES ('$title','$firstname','$middlename','$lastname','$housenoname','$address','$town','$county','$postcode','$number','$email')";
$sql_result=mysql_query($sqlstatement,$connection) or die("Couldn't execute the SQL statement");
$sqlstatement="INSERT INTO swinging_ship (RideSelection, Time, SeatNumber)
VALUES ('$rideselection','$time','$seatnumber')";
$sql_result=mysql_query($sqlstatement,$connection) or die("Couldn't execute the SQL statement");
print "<br />This seat is free - proceed";
}
Thanks,
Jordan
Comment