#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    I'm hosting an antique links area of my website. The links are dynamically pulled from a MySQL table via PHP pages. MySQL returns the valid web links depending on the category a viewer chooses.

    From the returned query results, I'd like to show "New Link" beside the name of those sites added in the previous 30 days. I'd like to do this in some manner other than manually updating the database table each day.

    When a site owner submits a site for linking, the php form pushes the current "created" date to a date field in the MySQL table.

    The way I see it, when a category link is pressed by the browser, PHP compares the current server date to the date in the link table. If the difference is less than or equal to "30", then I show "New Link" text. I have a mental block/tunnel vison on making the date comparison "if" work.

    Does anyone have experience with date comparisons to get me started in the general direction?

    Thank you.

    Scott Vickrey
    rooftop@antiqueappeal.com
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    The best way to do this is to use MySQLs built in date functions. If you've stored the date in any of the mysql time formats you can do this in your query:

    select other,fields,you,want,to_days(now())-to_days(date_field) as age from table where whatever

    Then in your php you can add a simple line:

    if ($row[age]<=30)
    {
    print "NEW!"; // or image or whatever
    }

Similar Threads

  1. need help in sorting&printing MySQL results
    By lowdog in forum MySQL Help
    Replies: 0
    Last Post: February 16th, 2004, 10:23 AM
  2. Can anyone help with mysql query and results?
    By msmith29063 in forum MySQL Help
    Replies: 3
    Last Post: February 8th, 2004, 03:43 AM
  3. Select a mysql result date range with a drop down
    By horstuff in forum PHP Development
    Replies: 0
    Last Post: January 31st, 2004, 02:33 PM
  4. MySQL Select query
    By MrTee1 in forum MySQL Help
    Replies: 0
    Last Post: January 30th, 2004, 11:16 AM
  5. mysql query to tab delimited file?
    By direwolf in forum PHP Development
    Replies: 1
    Last Post: January 17th, 2004, 01:46 AM

IMN logo majestic logo threadwatch logo seochat tools logo