...

View Full Version : Banner Rotation code



ostudioo
05-15-2007, 04:49 AM
$random_number = rand(1, 5);

$random_banner[1] = '<a href="http://www.blawgspot.com/"><img src="http://www.blawgspot.com/banner.gif" border="0" alt="BlawgSpot" style="float: right; padding: 7px;" /></a>';

$random_banner[2] = '<a href="http://forumpostie.easywebbers.com"><img src="http://forumpostie.easywebbers.com/ads/banner.gif" border="0" alt="ForumPostie" style="float: right; padding: 7px;" /></a>';

$random_banner[3] = '<a href="http://www.teenelement.com"><img src="http://images.teenelement.net/te_banner_FINAL.gif" border="0" alt="TeenElement" style="float: right; padding: 7px;" /></a>';

I currently using this code for my forum's banner rotation script. I have three questions for this code:

Question 1: I can have unlimited banners to be rotated right? The first line of code that has rand(1, 5); If I want more than 5 I just change that number?

Question 2: How can I set it to have a banner everytime? What I mean is, on my forum sometimes when I refresh it, it doesn't have a banner showing. Sometimes I would have to refresh it 3 times to have it show a random banner. I want a banner to be shown always, but of course have it rotated.

Question 3: How can I make the link be opened in a new window?

_Aerospace_Eng_
05-15-2007, 08:58 AM
1. Yes you can, just change the number.
2. Its because $rand_number is returning a number between 1 and 5 inclusively. Since you only have 3 banners it might return 4 or 5 and since you have no 4th or 5th images nothing shows up.
3. If you aren't using a strict doctype you can use target="_blank".
Finally all of these questions are 'Read the manual' type questions meaning learn to do a little more research on your own before asking simple questions.

smalldog
05-15-2007, 09:14 AM
As Aerospace said.. :) use this code instead.. it should work :)



$random_number = rand(1, count($random_banner));

$random_banner[1] = '<a href="http://www.blawgspot.com/"><img src="http://www.blawgspot.com/banner.gif" border="0" alt="BlawgSpot" style="float: right; padding: 7px;" /></a>';

$random_banner[2] = '<a href="http://forumpostie.easywebbers.com"><img src="http://forumpostie.easywebbers.com/ads/banner.gif" border="0" alt="ForumPostie" style="float: right; padding: 7px;" /></a>';

$random_banner[3] = '<a href="http://www.teenelement.com"><img src="http://images.teenelement.net/te_banner_FINAL.gif" border="0" alt="TeenElement" style="float: right; padding: 7px;" /></a>';

ostudioo
05-16-2007, 02:17 AM
Thx, but the code u gave me above doesn't random. It is ok, I got my own to work.

I was wondering if I can ask another question: How can I use the code below as a banner to be rotated?



<script type="text/javascript"><!--
auctionads_ad_client = "f6f7ea23731e71604b99";
auctionads_ad_campaign = "";
auctionads_ad_width = "468";
auctionads_ad_height = "60";
auctionads_ad_kw = "Test";
auctionads_color_border = "CFF8A3";
auctionads_color_bg = "FFFFFF";
auctionads_color_heading = "00A0E2";
auctionads_color_text = "000000";
auctionads_color_link = "008000";
--></script>
<script type="text/javascript" src="http://ads.auctionads.com/pagead/show_ads.js">
</script>

_Aerospace_Eng_
05-16-2007, 02:50 AM
Thx, but the code u gave me above doesn't random. It is ok, I got my own to work.

I was wondering if I can ask another question: How can I use the code below as a banner to be rotated?

The same way you got the others to rotate. Its only html. Smalldog's code would have worked if he put $random_number after the $random_banner array. The array isn't created yet so it doesn't know the count of the array.

ostudioo
05-16-2007, 05:51 AM
So just add $random_banner[4] = before the auctionad code?

smalldog
05-16-2007, 04:43 PM
Sorry that was my bad :) right code is this:



$random_banner[1] = '<a href="http://www.blawgspot.com/"><img src="http://www.blawgspot.com/banner.gif" border="0" alt="BlawgSpot" style="float: right; padding: 7px;" /></a>';

$random_banner[2] = '<a href="http://forumpostie.easywebbers.com"><img src="http://forumpostie.easywebbers.com/ads/banner.gif" border="0" alt="ForumPostie" style="float: right; padding: 7px;" /></a>';

$random_banner[3] = '<a href="http://www.teenelement.com"><img src="http://images.teenelement.net/te_banner_FINAL.gif" border="0" alt="TeenElement" style="float: right; padding: 7px;" /></a>';

$random_number = rand(1, count($random_banner));



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum