kade119 Posted April 7, 2010 Share Posted April 7, 2010 I'm trying to get my banner image to change to a specific image based on which page they choose, could someone help me? contact page > contact banner .jpg <?php $Img1 = "http://www.(the source of the image)"; $Alt1 = "[advertisement] (place your alt text here)"; $Url1 = "http://www. (the url of the link)"; $Img2 ="http://www.pro-dezign.com/images/banner.jpg"; $Alt2 = "[advertisement] pro-dezign web development"; $Url2 = "http://www.pro-dezign.com/index.html"; $num = rand (1,2); $Image = ${'Img'.$num}; $Alt = ${'Alt' .$num}; $URL = ${'Url'.$num}; Print "<a href=\"".$URL."\"><img src=\"".$Image."\" alt=\"".$Alt."\" /</a>"; ? > <?php include ("banner-rotator.php"); ?> Link to comment https://forums.phpfreaks.com/topic/197877-dynamic-banner-based-on-menu-item/ Share on other sites More sharing options...
hcdarkmage Posted April 7, 2010 Share Posted April 7, 2010 Are you using this code now to change the header? If you are, then it just randomly changes. You would probably want something like $page = "pagename"; $url = "pageurl"; $alt = "image alt" Print "<a href=\"".$url."\"><img src=\"".$page.".png\" alt=\"".$alt."\" /</a>"; Just name your images like Contact page = contact.png or whatever format you are using. Link to comment https://forums.phpfreaks.com/topic/197877-dynamic-banner-based-on-menu-item/#findComment-1038447 Share on other sites More sharing options...
kade119 Posted April 7, 2010 Author Share Posted April 7, 2010 can i put all of this "<a href=\"".$url."\"><img src=\"".$page.".png\" alt=\"".$alt."\" /</a>"; into a var so i can place it wherever i need it? Link to comment https://forums.phpfreaks.com/topic/197877-dynamic-banner-based-on-menu-item/#findComment-1038452 Share on other sites More sharing options...
hcdarkmage Posted April 7, 2010 Share Posted April 7, 2010 I don't see why you can't. $varname = "<a href=\"".$url."\"><img src=\"".$page.".png\" alt=\"".$alt."\" /</a>"; Link to comment https://forums.phpfreaks.com/topic/197877-dynamic-banner-based-on-menu-item/#findComment-1038455 Share on other sites More sharing options...
kade119 Posted April 7, 2010 Author Share Posted April 7, 2010 this script.. i don't really understand how this would make it more dynamic? it's the same as adding the <img /> itself, correcT? i just want to make my banner change based on the nav menu item selected home.php about.php contact.php Link to comment https://forums.phpfreaks.com/topic/197877-dynamic-banner-based-on-menu-item/#findComment-1038475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.