Reply
any ideas how to do this?
Old 01-15-2009, 03:13 PM any ideas how to do this?
Experienced Talker

Posts: 34
Trades: 0
hi I want to be able to calculate the this:I have a date column in mysql, this is the date when a product is added, then the user enters how many days a product must show, this is stored in days column, so I want to show all products that are from date column plus the days chosen in the days column, or all products that don't go pass the days chossen. any clue?? sort of stuck in this one!!lastly can anyone give me any performance tips in php? is there any core rules?thanks!!
Necaxa is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 01-15-2009, 06:15 PM Re: any ideas how to do this?
King Spam Talker

Posts: 1,413
Trades: 0
If I read that right, there are to ways to do it.

1. Determine the expiration when the item is entered and enter that value into a different field which is checked before the item is displayed.

2. Read the existing mysql values and script it so that
// If days are more than x from insertion date do not display

Frankly, I might be able to write the first one. The second is beyond my current ability.
__________________
Colbyt
colbyt is online now
Reply With Quote
View Public Profile
 
Old 01-15-2009, 07:02 PM Re: any ideas how to do this?
Banned

Posts: 35
Name: Brett Topovski
Location: Wooster, Ohio
Trades: 0
I think I can help you with this, please contact me if you still need help with this problem.
I have an example of what I think you are asking for.
The example I have to show you is live online currently.
seo_man is offline
Reply With Quote
View Public Profile
 
Old 01-15-2009, 07:18 PM Re: any ideas how to do this?
anderswc's Avatar
Super Talker

Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
Trades: 0
@seo_man, that's nice

@Necaxa, Assuming you have a datetime column called `date_added` and an integer column called `days_to_show` in a table called `products` here's the SQL statement you need.

Code:
SELECT *
FROM `products`
WHERE ADDDATE(`date_added`, `days_to_show`) >= CURDATE()
Code seems pretty self explanatory to me, but if you need anything explained, give a shout out.
__________________
Will Anderson
It's An Anderson | Twitter | Anderson Web Solutions
anderswc is offline
Reply With Quote
View Public Profile Visit anderswc's homepage!
 
Old 01-15-2009, 07:23 PM Re: any ideas how to do this?
chrishirst's Avatar
Super Moderator

Posts: 22,282
Location: Blackpool. UK
Trades: 0
Use the SQL server to do the calculation

Code:
SELECT fieldlist FROM table WHERE CURDATE() BETWEEN datecolumn AND DATE_ADD(datecolumn, INTERVAL daycountcolumn, DAY);
not tested but looks ok
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-15-2009, 09:03 PM Re: any ideas how to do this?
Experienced Talker

Posts: 34
Trades: 0
thanks a lot, I'll give it a try and get back to you.here is something abit more complicated....I am using ajax to submit form.in the form you can upload pics, so when I press "upload" the pics are uploaded ,then press "send" and the values of the file/text box are sent to db. in my local pc I use $location ="upload/".basename(textbox) then on my db I get "upload/bla.jpg", now I just tested it on server and it gives this "upload/C:/folder/bla.jpg"? any ideas? ajax is tricky! I tried to put the name of the image in a hidden field in the upload script but is not being posted, so I am stuck! lastly any of you guys know how to speed up a site?
Necaxa is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to any ideas how to do this?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.13300 seconds with 13 queries