Jump to content

Archived

This topic is now archived and is closed to further replies.

DantePhlegethon

If-Else Linking.

Recommended Posts

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.


Share this post


Link to post
Share on other sites
This will do all the months in the year.

1 make a folder called images.

2. make images a - i . gif

good 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]

Share this post


Link to post
Share on other sites
<?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?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.