longhollow Posted June 4, 2009 Share Posted June 4, 2009 Hi, I'm not a php guy. Several months ago folks here suggested the code below. It has been working very well. It displays 5 lines of content, url links, from stored .txt files. Each day a new line is added and one falls off. <?php for($i=1; $i>=-3; $i--) { $today = date("z",(time()-3600))+$i; ?> - <? INCLUDE "/usr/home/bcmurray/public_html/features/$today.txt";?> <BR> <?php } ?> Now my users have asked me to offer a new page that shows an archive of my past url links. So, I need to modify the code to display all the url links for the year. It needs to start counting backwards from todays date and stop on day 1. Any help would be greatly appreciated. Thanks, Bruce Quote Link to comment Share on other sites More sharing options...
fanfavorite Posted June 4, 2009 Share Posted June 4, 2009 You should just be able to do change: for($i=1; $i>=-3; $i--) { to for($i=1; $i>=-364; $i--) { This should give you the links for the past 365 days. Quote Link to comment Share on other sites More sharing options...
longhollow Posted June 4, 2009 Author Share Posted June 4, 2009 Thanks for the suggestion. I had already tried that.... Need it to only show this years entries, counting backwards from todays date to day "1". Suggested script breaks as it passes day "1" and starts requesting negative file numbers. Thanks, Bruce Quote Link to comment Share on other sites More sharing options...
fanfavorite Posted June 4, 2009 Share Posted June 4, 2009 Ok try this: <?php for($i=1; $i>=-364; $i--) { $today = date("z",(time()-3600))+$i; ?> - <? INCLUDE "/usr/home/bcmurray/public_html/features/$today.txt";?> <BR> <?php if ($today == 0) { exit; } } ?> Quote Link to comment Share on other sites More sharing options...
longhollow Posted June 4, 2009 Author Share Posted June 4, 2009 Almost perfect. Broke on the last output line. Changed if($today == 0) to ==1 and it works great ending output on the 1st day of the year! Thanks so much for your help! Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted June 5, 2009 Share Posted June 5, 2009 if the problem is solved please click the Topic Solved Button at the bottom left of the page Quote Link to comment 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.