jeff5656 Posted January 31, 2009 Share Posted January 31, 2009 I have 12 files called april.htm, may.htm etc one for each month. Can I insert php code into this: <li><a href="schedules/february.htm" class="navText">next month</a></li> to display the apprpriate month? For instance if someone clicked the href link for "next month" it would go to the file named "february.htm" (because today is January), but if someone clicked the SAME link during March, it would call up the named "April.htm. Link to comment https://forums.phpfreaks.com/topic/143282-solved-go-to-a-given-page-based-on-todays-date/ Share on other sites More sharing options...
void Posted January 31, 2009 Share Posted January 31, 2009 this is completely written from my mind, you might get some errors, but should get the idea. $next_month = strtotime("+1 month",mktime(0,0,0,date("n"),1,date("Y"))); $next_month_label = date("F",$next_month); $link = strtolower($next_month_label).'.html'; echo '<li><a href="schedules/'.$link.'" class="navText">'.$next_month_label.'</a></li>'; Link to comment https://forums.phpfreaks.com/topic/143282-solved-go-to-a-given-page-based-on-todays-date/#findComment-751466 Share on other sites More sharing options...
ialsoagree Posted January 31, 2009 Share Posted January 31, 2009 Oh, nevermind, I totally missed that the above poster had already done that. Link to comment https://forums.phpfreaks.com/topic/143282-solved-go-to-a-given-page-based-on-todays-date/#findComment-751469 Share on other sites More sharing options...
jeff5656 Posted February 2, 2009 Author Share Posted February 2, 2009 Thanks! That worked, but I did have to modify the code slightly. Here it is for the record: <a href="schedules/<?php echo $link;?>" class="navText"> Link to comment https://forums.phpfreaks.com/topic/143282-solved-go-to-a-given-page-based-on-todays-date/#findComment-752505 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.