Re: Banner rotation problem!

From: Date: Sun, 26 Nov 2000 00:45:20 +0000
Subject: Re: Banner rotation problem!
Groups: php.general 
Request: Send a blank email to php-general+get-27200@lists.php.net to get a copy of this message
Addressed to: "Samuel Abreu" <mouse@baydenet.com.br> php-general@lists.php.net ** Reply to note from "Samuel Abreu" <mouse@baydenet.com.br> Sat, 25 Nov 2000 11:51:36 -0200 > > Hi list! > > I trying to do a banner rotation script, it something like this: > > >banner.php: > <? header ("Location: banner.jpg"); /* In this example is just one file, > but will have a code to generate always a diferent file for show... */ ?> > > > Ok, in a common page if i put a tag: <img src="banner.php"> it will show > the file, but the problem is if i have 3 files with the respective > website to go, for example: one.jpg -> http://www.one.com > two.jpg -> > http://www.two.com three.jpg -> > http://www.three.com > > What i put in <a href=??? > > How can i make the link to a script for it redirectly to the respective > page?? $Banners = array( 'one.jpg' => 'http://www.one.com', 'two.jpg' => 'http://www.two.com', 'three.jpg' => 'http://www.three.com' ); $Keys = array_keys( $Banners ); $Image = $Keys[ time() % count( $Keys )]; $URL = $Banners[ $Image ]; ?> <A href-"<?=$URL?>"> <img src="/images/banners/<?=$Image?>"> </A> <? Some might say that time() isn't random enough, but I say that (in this case) which of three consecutive seconds you hit the web site at is random enough to select which banner ad to display. The randomness is not a based on the time() function, but when the page is hit. Rick Widmer Internet Marketing Specialists http://www.developersdesk.com

« previous php.general (#27200) next »