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 Link to comment https://forums.phpfreaks.com/topic/160982-need-to-modify-this-code/ 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. Link to comment https://forums.phpfreaks.com/topic/160982-need-to-modify-this-code/#findComment-849576 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 Link to comment https://forums.phpfreaks.com/topic/160982-need-to-modify-this-code/#findComment-849589 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; } } ?> Link to comment https://forums.phpfreaks.com/topic/160982-need-to-modify-this-code/#findComment-849599 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! Link to comment https://forums.phpfreaks.com/topic/160982-need-to-modify-this-code/#findComment-849626 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 Link to comment https://forums.phpfreaks.com/topic/160982-need-to-modify-this-code/#findComment-849688 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.