Jump to content

Show if an entry is x days old


ingvaro

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.