4 Replies - 167 Views - Last Post: 22 January 2012 - 06:17 AM

Topic Sponsor:

#1 decongh  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 39
  • Joined: 31-December 11

php function to count days every day

Posted 17 January 2012 - 02:25 AM

Hi, Am building a car sale site.I want to automatically take of listings that are more than, say 14 day old.

Any php/mysql scripts or an idea as to how to do this?
Is This A Good Question/Topic? 0
  • +

Replies To: php function to count days every day

#2 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 2145
  • View blog
  • Posts: 5,420
  • Joined: 08-June 10

Re: php function to count days every day

Posted 17 January 2012 - 02:38 AM

there are two possible routes in general.
1) make a MySQL function/procedure that only returns those valid listings
2) specify it in the fetching SQL string. something along SELECT item FROM listings WHERE DATE_ADD(item_created, INTERVAL 14 DAY) > NOW()

This post has been edited by Dormilich: 17 January 2012 - 02:40 AM

Was This Post Helpful? 2
  • +
  • -

#3 decongh  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 39
  • Joined: 31-December 11

Re: php function to count days every day

Posted 17 January 2012 - 01:58 PM

Thank you for your help.I need one for clarification,is this
item_created
a filed in the db as well?

Thank you for your help.I need one more clarification,is this
[b]item_created[/b]
a filed in the db as well? If so what data type will it be, Date type?
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 2145
  • View blog
  • Posts: 5,420
  • Joined: 08-June 10

Re: php function to count days every day

Posted 17 January 2012 - 02:29 PM

it’s the data field where you store the date/time when you created the listing. it would be sensible to define it along

item_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP

Was This Post Helpful? 2
  • +
  • -

#5 decongh  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 39
  • Joined: 31-December 11

Re: php function to count days every day

Posted 22 January 2012 - 06:17 AM

Hi Dormilich, am very thankful for your help,it worked just perfect,thanks alot
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1