Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Add period and price for that period

Add period and price for that period



9:25 pm on Oct 6, 2012 (gmt 0)

5+ Year Member

I'm working on a travel website and i need to add a complicated function (complicated for me)when adding an offer, that includes date period (FROM DATE until TO DATE) and a price for that period. Ex:

01.10.2012 - 10.10.2012 - 399
15.10.2012 - 24.10.2012 - 429
03.11.2012 - 15.11.2012 - 439 ...

So, in this way, i can tell the visitors that this offer is available for those dates for that price.
I suppose that it can be done by implode date range (01.10.2012 - 10.10.2012,01.10.2012 - 10.10.2012,01.10.2012 - 10.10.2012) or by implode sepparetly FROM DATE (01.10.2012,01.10.2012,01.10.2012) and TO Date (10.10.2012,24.10.2012,15.11.2012) and by implodeing price also (399,429,439), and then to explode tham to correspond each one, but i don;t know how to do it. I only know that, teoritically, it can be down in this way. Also, i need to have a button/link that, when i click on it, appear a new html row when can i insert period/dates and prices.

I'm new on PHP/MySql and i don't know how to do it. Can someone help me on this?

Hope that i was understandable enough and some will help me with this solution.
Thank you in advance!


10:40 am on Oct 7, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

I'd never consider merging such data into a field in a database, you kill all a relational database could do for you.

- Just remove all pricing info out of your product table (yes, all of it)
- Add a table to hold pricing e.g.:
priceid unsigned int autoincrement
productid unsigned int
start date
end date
price unsigned int
- maybe add a default price either be not having a date range supplied on that line in the pricing table, or either by referencing the priceid from the product line, or by having a date range from 0000-00-00 to 9999-12-31 and a "rule" to use the most specific price in priority (I'd prefer the latter).

All you need to do to find all the prices, just the currently valid prices, or the default price is just a SQL query away (learn about JOIN if you have to)

Keeping your data this way is the only future proof way IMHO.


2:39 pm on Oct 7, 2012 (gmt 0)

5+ Year Member

Thank you very much.
After i started this thread, i was thinking about your idea, and i thought it's better to use this way, and i started working on it. Now, i have finished it and it works like a charm.
Anyway, thank you very much for your reply and for making me happy, since i was thinking like you, too ;)

Featured Threads

Hot Threads This Week

Hot Threads This Month