ingvaro Posted December 10, 2006 Share Posted December 10, 2006 Im trying to make a code that shows if an entry of my database is, say 7 days old.So far ive got this[code]if ($_GET['show'] == 'list') while ( $row = mysql_fetch_array( $result )) if ($row[ 'id' ]>48){ echo " <a href=\"index.php?site=gallery/galleries.php&type=allt&page=0&number=10&show=gallery&gallery=yes&gallery_nr={$row[ 'linkur' ]}\" target=\"_parent\"> <div class=\"gallery_menu\"> <img src=\"gallery/thumbs/{$row[ 'linkur' ]}.jpg\" alt=\"description\" width=\"60\" height=\"60\" border=\"0\" /> <p><strong>{$row[ 'titill' ]} - {$row[ 'date' ]} - ({$row[ 'clicks' ]}) - Nýtt!</strong> </p> <p>{$row[ 'description' ]}</p> </div> </a>";}else { echo " <a href=\"index.php?site=gallery/galleries.php&type=allt&page=0&number=10&show=gallery&gallery=yes&gallery_nr={$row[ 'linkur' ]}\" target=\"_parent\"> <div class=\"gallery_menu\"> <img src=\"gallery/thumbs/{$row[ 'linkur' ]}.jpg\" alt=\"description\" width=\"60\" height=\"60\" border=\"0\" /> <p><strong>{$row[ 'titill' ]} - {$row[ 'date' ]} - ({$row[ 'clicks' ]})</strong> </p> <p>{$row[ 'description' ]}</p> </div> </a>";}[/code]this works, and if the id of the entry is higher than 48 it says that the entry is new, and if its less than 48 it just echoes the entry, with no "new" status.But i need this to be dynamic, so that it just does things automatically, like if the entry date is 7 days older than today it says nothing, but if it is older than less than 7 days (dont know how to say this really :)), then it says "NEW" :)Hope you get my point hehe Link to comment https://forums.phpfreaks.com/topic/30111-show-if-an-entry-is-x-days-old/ Share on other sites More sharing options...
ted_chou12 Posted December 10, 2006 Share Posted December 10, 2006 do you achieve that by subtracting the entered time from the current time? Link to comment https://forums.phpfreaks.com/topic/30111-show-if-an-entry-is-x-days-old/#findComment-138430 Share on other sites More sharing options...
ingvaro Posted December 10, 2006 Author Share Posted December 10, 2006 [quote author=ted_chou12 link=topic=118054.msg482072#msg482072 date=1165751318]do you achieve that by subtracting the entered time from the current time?[/quote]Sorry but i dont understand, could you explain that? :D(Been in this PHP/MySQL thing for only a week) Link to comment https://forums.phpfreaks.com/topic/30111-show-if-an-entry-is-x-days-old/#findComment-138432 Share on other sites More sharing options...
ted_chou12 Posted December 10, 2006 Share Posted December 10, 2006 here, read this, maybe you will be able to get my point:http://www.ilovejackdaniels.com/php/php-datediff-function/EDITED: actually i think there might be a simple php function to do that... Link to comment https://forums.phpfreaks.com/topic/30111-show-if-an-entry-is-x-days-old/#findComment-138438 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.