Jump to content

If-Else Linking.


DantePhlegethon

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.


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.