troubleshooting Question

How do I do a correct check?

Avatar of Lennart Ericson
Lennart EricsonFlag for Sweden asked on
Web DevelopmentPHPMySQL Server
14 Comments1 Solution363 ViewsLast Modified:
Experts and Gurus, I am making a booking application for a small parking place. It has five places. Customers can book one car for one 24-hour period up to seven 24-hour periods.
Apart from registering the name, register plate information etc pertaining to the parker, I have a data base table like this:

id , parking_space_nr, arrival_day, departure_day, arrival_code, departure_code, reference_nr, 24_hrs_periods

Arrival_code and departure_code is UNIX time for arrival_day and departure_day respectively.

There is a grace period built in:
$code_of_arrival = strtotime($_POST['day_of_arrival']) + 46800;
$code_of_departure = ($code_of_arrival + ($_POST['24_hrs_periods'] * 86400) - 3600);

If I need to join the two data base tables it is done on reference_nr.

I have tried to construct a piece of code to find out whether a certain parking_space_nr is free or not the day a customer wants to book:
$SQL = "SELECT * FROM platser WHERE arrival_code between '$code_of_arrival' AND '$code_of_departure' AND parking_space_nr = '1' ";
$ret = mysql_query($SQL);
if (!$ret) { echo("[0] ".mysql_error()); }
else {
$number_of_bookings = mysql_num_rows($ret);
}
if($number_of_bookings > 0) {  the particular parking_space_nr is not free and a parking prohibited sign is shown for that parking_space_nr }
else  { a parking allowed sign is shown  }

I would like to ask you gurus and experts how to construct the piece of code to correctly find out whether the parking space is free or not.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros