Jump to content

Dynamic Banner based on menu item


kade119

Recommended Posts

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

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.

Archived

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

×
×
  • 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.