ManyCodes.com – codes & scripts Get free programming codes and tutorials!

13Feb/100

Display a different image for each day of the week

This PHP code will help you get the day of the week from the server date and then display an image (jpg or gif) to match.

<?php
/**
* Change the name of the image folder
*
* Images must be named Monday.gif, Tuesday.gif etc
*/
// Change to the location of the folder containing the images
$image_folder = "images/days";

// You do not need to edit below this line
$today = date('l');
if (file_exists($image_folder."/".$today.".gif")) {
echo "<img src=\"$image_folder/".$today.".gif\">";
}
else {
echo "No image was found for $today";
}
?>

The above code is referenced from http://www.totallyphp.co.uk

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Webnews
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Ask
  • Facebook
  • Technorati
  • YahooBuzz