homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Add period and price for that period
Add period and price for that period

5+ Year Member

Msg#: 4504941 posted 9:25 pm on Oct 6, 2012 (gmt 0)

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!



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

Msg#: 4504941 posted 10:40 am on Oct 7, 2012 (gmt 0)

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.


5+ Year Member

Msg#: 4504941 posted 2:39 pm on Oct 7, 2012 (gmt 0)

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 ;)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved