jduffell Posted May 20, 2008 Share Posted May 20, 2008 Hi, it's either going to be complicated or easy, but i'm trying to find a script which will add an image after a link to represent a new post. I'm basically using a database to store links which are then displayed in alphabetic order, and when i add a new link to the database i want an image to appear next to the link for a week after it's posted and then it's removed. Any help welcome, cheers Quote Link to comment https://forums.phpfreaks.com/topic/106504-php-new-post/ Share on other sites More sharing options...
DeanWhitehouse Posted May 20, 2008 Share Posted May 20, 2008 from what i know you need to use a loop , and a cron job to change the image every week, the loop is to show it . How are you displaying the links? Quote Link to comment https://forums.phpfreaks.com/topic/106504-php-new-post/#findComment-545919 Share on other sites More sharing options...
thebadbad Posted May 20, 2008 Share Posted May 20, 2008 I would use CSS to make the image part of the link, like this: <style type="text/css"> a.new { background: transparent url("path_to_small_image") no-repeat center right; padding-right: 20px; } </style> <a class="new" href="">Link</a> And if your page is viewed even just once a day, you won't need a cron job. Just store a timestamp or date along with the link, and check how old it is when echoing it. Quote Link to comment https://forums.phpfreaks.com/topic/106504-php-new-post/#findComment-545929 Share on other sites More sharing options...
thebadbad Posted May 20, 2008 Share Posted May 20, 2008 Come to think of it, it doesn't matter how often it's viewed when you check the dates each time the links are echoed. Quote Link to comment https://forums.phpfreaks.com/topic/106504-php-new-post/#findComment-545935 Share on other sites More sharing options...
deadonarrival Posted May 20, 2008 Share Posted May 20, 2008 Store a "last edited" timestamp along with the list. (Make it when the thread is created, then update whenever there's a post/edit Then when you show the threads, simply do print $name; if($last_edited > ($now - 60200)) { print "image tag"; } (Make $now = time(); somewhere above, I tend to define it on page load) Quote Link to comment https://forums.phpfreaks.com/topic/106504-php-new-post/#findComment-545941 Share on other sites More sharing options...
jduffell Posted May 20, 2008 Author Share Posted May 20, 2008 Cheers for all your help, i shall let you know how i got on Quote Link to comment https://forums.phpfreaks.com/topic/106504-php-new-post/#findComment-545966 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.