Forum Moderators: coopster

Message Too Old, No Replies

Selecting individual prices between two price ranges? Php/mysql

Listing the correct price per day when using different price ranges.

         

lasko

8:53 am on Jul 30, 2003 (gmt 0)

10+ Year Member



Hi all,

I am planning an on-line booking program and at one stage I will have to compile a list of the price per day of the prelimary booking.

The problem is that someone will select a date range that falls between two price ranges

price range from 01 - 02 = 100 euro
price range from 03 - 05 = 150 euro

I will need to then compile a list with the price per day then the total price at the bottom.

For example:

01:01:2003 - 100 Euro
02:01:2003 - 100 Euro
03:01:2003 - 150 Euro
---------------------
Total Price: 350 Euro

So my program will have to some how select the price for each individual day. Maybe by selecting each date seperatly.

Will I have to split the dates first like

01:01:2003
02:01:2003

then go through each date using

SELECT PRICE WHERE 01:01:2003 BETWEEN fromdate AND todate

I am fairly new to Php so any help or tips would be very appreciated.

Cheers

vincevincevince

12:51 pm on Jul 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



that sounds pretty much perfect - if it was me however i'd use the UNIX timestamp in your database and queries, then convert it for output using date();

lasko

1:00 pm on Jul 30, 2003 (gmt 0)

10+ Year Member



Hi

I always use the time stamp its the best way, but how do create a list of each day between the dates and then select the price for that date?

I know the logical thinking of it just not the code to put it into practice :(

vincevincevince

11:11 pm on Jul 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



pretty much like you said

store the start date (as timestamp) and end date (as timestamp) of each period
then do select where ('$wantedtime' > start_date

or similar :)

lasko

6:46 am on Jul 31, 2003 (gmt 0)

10+ Year Member



Hi Vincevincevince

I will see if i can come up with something.

One thing though, this is before it goes into a mysql database.

Basically the person requires to book 1 apartment and has selected 4 or 5 days before they can confirm the booking I must provide an intinary of their selection so a list is required of the apartment, the dates from and to and the total price. When they click total price I have to generate the list of each day with the correct price remembering that some days will be a different price. Then the customers clicks confirm booking and it will all be inserted into a mysql database.

Will try and create some test code and see what happens.

Cheers :)

vincevincevince

9:00 am on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



should be doable ok
to increase speed and reduce load you could put in every day of the year with the relevant cost
it would be more work to set up the database, but easier afterward