linkjg Posted May 6, 2007 Share Posted May 6, 2007 Hello! My personal website has a new banner each month for holiday themes. (I have a Christmas and Halloween banner, etc) Right now, I have to manually switch out the picture each month. Is there a free PHP code that would switch out the banner for me? ??? Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/50263-php-code-to-switch-out-banner-by-month/ Share on other sites More sharing options...
MadTechie Posted May 6, 2007 Share Posted May 6, 2007 switch the link to the image to a php script with an image header and then on preset dates the script can point to different files see below EDIT: call this image.php and replace your banner.jpg with image.php <?php function LoadJpeg($imgname) { $im = @imagecreatefromjpeg($imgname); /* Attempt to open */ if (!$im) { /* See if it failed */ $im = imagecreatetruecolor(150, 30); /* Create a black image */ $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); /* Output an errmsg */ imagestring($im, 1, 5, 5, "Error loading $imgname", $tc); } return $im; } header("Content-Type: image/jpeg"); $today = getdate(); switch($today['mon']) { default: case 1: $img = LoadJpeg("Jan.image.jpg"); break; case 2: $img = LoadJpeg("Feb.image.jpg"); break; case 12: $img = LoadJpeg("xmas.image.jpg"); break; } imagejpeg($img); ?> its a start **UNTESTED i guess this is free Quote Link to comment https://forums.phpfreaks.com/topic/50263-php-code-to-switch-out-banner-by-month/#findComment-246730 Share on other sites More sharing options...
linkjg Posted May 6, 2007 Author Share Posted May 6, 2007 Thanks!! I'll give it a try!! Quote Link to comment https://forums.phpfreaks.com/topic/50263-php-code-to-switch-out-banner-by-month/#findComment-246767 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.