DantePhlegethon Posted September 9, 2006 Share Posted September 9, 2006 If-Else Linking. Hello, I am completely new to this forum so you must forgive me if this topic has been covered before. Thank you. I am trying to set up a link that changes its destination depending on what month it is. Its not exactly a calendar that I am looking for, it’s simply a link to different pages. I am also “fairly new” to PHP so any help you can give or direction you can point me in would be greatly appreciated. All I need is a Text or Graphic Link that: • Depending on what month it is, displays a different page. • Tracks the month with a PHP Variable. Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 9, 2006 Share Posted September 9, 2006 This will do all the months in the year.1 make a folder called images.2. make images a - i . gifgood luck.[code]<?php$month=date("m");if($month=="01"){$pic="images/a.gif";}elseif($month=="02"){$pic="images/b.gif";}elseif($month=="03"){$pic="images/c.gif";}elseif($month=="04"){$pic="images/d.gif";}elseif($month=="05"){$pic="images/e.gif";}elseif($month=="06"){$pic="images/f.gif";}elseif($month=="07"){$pic="images/g.gif";}elseif($month=="08"){$pic="images/h.gif";}elseif($month=="09"){$pic="images/i.gif";}elseif($month=="10"){$pic="images/j.gif";}elseif($month=="11"){$pic="images/k.gif";}elseif($month=="12"){$pic="images/l.gif";}echo "<img src='$pic'></img>";?>[/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 9, 2006 Share Posted September 9, 2006 <?php$month = strtolower(date("F")); // gets the lowercase month name for the current dateecho "<a href='". $month. ".php'><img src='images/". $month. ".gif'"></a>";?>If the month is September, for example, then the link will go to september.php and the clickable image in the link will be september.gif ... you get to create all the images and .php files yourself.Is that sort of what you were looking for? Quote Link to comment Share on other sites More sharing options...
DantePhlegethon Posted September 10, 2006 Author Share Posted September 10, 2006 Thank you for your help, this is exactly what I was looking for. 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.