Jump to content


Photo

If-Else Linking.


  • Please log in to reply
3 replies to this topic

#1 DantePhlegethon

DantePhlegethon
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 09 September 2006 - 07:52 PM

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.




#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 September 2006 - 08:05 PM

This will do all the months in the year.

1 make a folder called images.

2. make images a - i . gif

good luck.

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

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 09 September 2006 - 08:23 PM

<?php
$month = strtolower(date("F")); // gets the lowercase month name for the current date
echo "<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?
Legend has it that reading the manual never killed anyone.
My site

#4 DantePhlegethon

DantePhlegethon
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 10 September 2006 - 03:08 AM

Thank you for your help, this is exactly what I was looking for.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users