Jump to content

Auto links


Hooch

Recommended Posts

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

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

<?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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...