Hey Sorry for the late response. I have done something similar but for a bed and breakfast, Room reservation system.
Please kindly start by normalizing your database properly.
you can have three tables such as Car, Hire, or Person. your car table, can have all the description of your vehicle. Person table can have all the description of the person hiring the car. your hire table will reference the car_id and person_id. It will also have you start_date and end_date. So like this.
- car table.
car_id (primary key), car_color (text), Car_make(text)
**
- Person table
** person_id (primary key) person_name (text) person_telephone (text)
Hire table Hire_Id(auto_increment) person_id (foreign key) car_id (foreign key) start_date (date) end_date (date)
$Query="SELECT r.* FROM car r WHERE r.car_id NOT IN ( select b.car_id from hire b where NOT (b.end_date< '2014-08-15' or b.start_date>'2014-08-12')) order by r.car_id;"
This return all available cars