Jump to content

switch banners


Xtazy

Recommended Posts

ok, so I have two banners for my website (till now), and I want them to be changed everytime the guest moves from one page to another one...even though he is in index.html, when he refreshes the page i want the banner changed...i think i should have posted this on the javascript category, dunno...thanx in advance!xtazy

Link to comment
Share on other sites

All you need is a random number generator, like this one:http://www.php.net/manual/en/function.mt-rand.phpOnce you generate a random number you can do whatever you want with it. You can get a record from the database with the number as an ID, use it to refer to an element in an array, use it to refer to a numbered file, whatever you want to do.

Link to comment
Share on other sites

Ah well, I've finally found a good script. Take a look:

	  <?php	  $banner[1]['link'] = "http://something.com";	  $banner[1]['img'] = "picture.jpg";   	  $banner[2]['link'] = "http://something.com";  	  $banner[2]['img'] = "picture.jpg";   	      	  $banner[3]['link'] = "http://something.com";	  $banner[3]['img'] = "picture.jpg";	  $banners=3; 	  srand((double)microtime()*1000000); 	  $random = rand(1,$banners);	  echo "<a href=\"".$banner[$random]['link']."\"><img src=\"".$banner[$random]['img']."\" border=\"0\"></a>";  	  ?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...