You are here: between dates sql/php « PHP SQL « IT news, forums, messages
between dates sql/php

Posted by ad on 10/13/56 11:46

Hi,
I creating a reservation style system which books out rooms for periods
of time. I need way of seeing which rooms are currently booked out.

At the moment I have the following - a table for the accomodation and a
booking table (student_accom with foriegn key) This query finds all the
rooms that are not booked - sort of...

Problem I'm having is:
If a room is booked from 2005-05-16 to 2005-06-22 and a someone tries
to make a reservation for dates outside both the checkin and checkout
times, then the room is shown as free..e.g. checkin 2005-05-14 to
2005-06-27 will show the room that was booked above as free. Can anyone
assist? I'm sure this has been done many times before.

Appreciate any assistance
Thanks

SELECT accomodation.* FROM accomodation left join student_accom
ON accomodation.accom_id = student_accom.accom_id AND
(
('" . $checkin_rs_accom_avail . "' between student_accom.start_date and
student_accom.leave_date) or
('" . $checkout_rs_accom_avail . "' between student_accom.start_date
and student_accom.leave_date)
)
WHERE (student_accom.start_date IS NULL or student_accom.leave_date IS
NULL) and accomodation.town = '" . $accomtown_rs_accom_avail . "' order
by rand()"

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация