Hooch Posted May 27, 2006 Share Posted May 27, 2006 Hi everyone. I have a question for the guru's here. I want to make a link that can tell what month it is, then have it direct the user to that month's webpage. The webpage has 12 months of activities, and it would be nice to have the home pagewith one "events" link that will direct you to the present month webpage. Can this be done without a database too? Thank you..Hooch Link to comment Share on other sites More sharing options...
reportingsjr Posted May 27, 2006 Share Posted May 27, 2006 actually thats very easy... $month=date('n');if(month == "1"){echo '<a href="www.site.com/month1">month 1 activities</a>';}elseif(month == "2"){echo '<a href="www.site.com/month1">month 2 activities</a>';}elseif(month == "3"){echo '<a href="www.site.com/month1">month 3 activities</a>';}elseif(month == "4"){echo '<a href="www.site.com/month1">month 4 activities</a>';}else{} I think you get the picture.. date('n') shows the number of the month, starting with january.. so whatever month it is just check out the number for it..to learn more about date() check out this:http://www.w3schools.com/php/func_date_date.asp Link to comment Share on other sites More sharing options...
SFB Posted May 27, 2006 Share Posted May 27, 2006 <?php$month = date('F');echo"<a href='http://yoursite/$month.ext'>$month</a>";?> just make each file the name of the month and then you can change .ext in the code above to what ever extension you are using (ie .html, .php .xml .....)Edit: I didnt realize someone else was replying at the same time i was. Link to comment Share on other sites More sharing options...
reportingsjr Posted May 27, 2006 Share Posted May 27, 2006 well, you could do it his way.. but if the href has a special name or the file has to then just do it my way..[*EDIT] lol SFB, now he has two solutions instead of one. better for everyone! Link to comment Share on other sites More sharing options...
Hooch Posted May 27, 2006 Author Share Posted May 27, 2006 Awsome thanks guys. This gives me ideas for other things. PHP is amazing to say the least.Installed an working like a charm. Thanks a bunch!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now