Search in between dates

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sathumenon
Forum Newbie
Posts: 5
Joined: Wed Mar 08, 2006 3:02 am

Search in between dates

Post by sathumenon »

Hello

I hav to do a rental site. And here the user can search for a property where he arrives on adate and will be staying till another date. I want to search the properties available On and in between this dates.

Infact am not sure how to do this. any tutorials are available, to fetch the availabitliy of a property betwen teh dates the user entering and to display?
also how the tables to be designed for the booking and al?

Many Thanks
Sathish
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

How are you storing the dates? Do you have any code started?

Mac
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Search in between dates

Post by RobertGonzalez »

sathumenon wrote:Hello

I hav to do a rental site. And here the user can search for a property where he arrives on adate and will be staying till another date. I want to search the properties available On and in between this dates.

Infact am not sure how to do this. any tutorials are available, to fetch the availabitliy of a property betwen teh dates the user entering and to display?
also how the tables to be designed for the booking and al?

Many Thanks
Sathish
Depending on your database, look into their version of the BETWEEN function.
sathumenon
Forum Newbie
Posts: 5
Joined: Wed Mar 08, 2006 3:02 am

Helo

Post by sathumenon »

Hi

Thanks for replying. Infact I was looking for some tutorials if available. So that I can start my own. I hav created a property table only with the property features. And not sure of how to store the dates of booking.

If a party comes and books for 5 days say from May28th to 1st June. How we can store that in to table for the puspose of searching and finding the available dates for that property?

Thanks
Sathish
Soogn
Forum Newbie
Posts: 11
Joined: Sat May 27, 2006 12:53 pm

Post by Soogn »

Maybe not appropriate, but i just helped a friend with his college work.. bookigns for a chruch hall, in that model, we stored bookings in another table.... bookings had [id][userid][start][end][confirmed] - confirmed was just a bool field, confirmed by phone - and id, and userid - easy enough to understand, the start and end were timestamp fields.

In this instance we coded (though i don't have them to hand) a serise of macro type things

Code: Select all

IsAvailable($property_id, $from_stamp, $to_stamp)
I know this is far from a comlpete solution, but i'm just about to go out with the family, when i get back (if someone hasn't beat me to it!) I'll try and protoype the fucntion for you.
sathumenon
Forum Newbie
Posts: 5
Joined: Wed Mar 08, 2006 3:02 am

Will try this

Post by sathumenon »

Hello

Thanks a lot for the idea. Infact I designed a table similar to this, with Date Id, Property Id, Arrival Date, Departure Date.
I think this might work! Let me try!!!! :wink:

Thanks again
Sathish
Post Reply