I am making hotel booking online application and for the booking i am using table like this hotelid, personname,startdate,enddate startdate is a date of check in and enddate is date of check out. I want to know if date is like this start date : 07/14/2010 end date : 07/21/2010 How can i find that room is book for 15-20 date too?
Your description is vague?? But if I understand you correcty; try this (it would check if a record exists with the specified start and end date): <?php //replace table_name with the name of your table $check = mysql_num_rows(mysql_query("SELECT * FROM table_name WHERE startdate = '07/14/2010' AND enddate = '07/21/2010'")); if ($check > 0) { echo "Record Exists"; } ?> PHP:
If I understand it correctly, I think he would actually want "..WHERE startdate >= '07/14/2010' AND enddate <= '07/21/2010'" since if he would need to know if all the rooms are booked any day between or not as well
Theirfore I thought the OP meant, (s)he'd like to check if the record exists with them specific rows? But if the OP did meant what you pointed out, then that would be the correct way to go.