<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Simple PHP Banner Ad Rotator Script</title>
	<atom:link href="http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/</link>
	<description>Technical Articles, Musings and Opinions from Tech-Evangelist</description>
	<lastBuildDate>Sun, 29 Jan 2012 19:09:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Doogie</title>
		<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/comment-page-1/#comment-23941</link>
		<dc:creator>Doogie</dc:creator>
		<pubDate>Sun, 29 Jan 2012 19:09:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/#comment-23941</guid>
		<description>Hi Ang

You could set up two arrays and modify the code so that a pair of ads displays together each time. 

Example: 

$bannerAd1[1] = &#039;code for ad 1 for banner 1&#039;;
$bannerAd2[1] = &#039;code for ad 1 for banner 2&#039;;

You cannot force it to loop through a series of ads in a sequential order unless you use a database or some way to keep track of a number that is incremented as each ad is displayed. That would be cumbersome. 

It may be possible to do this with a cookie so that a user picks up the cookie and sees the first ad, then when the next page is loaded the number is incremented and they see the second ad and so on. When they reach the last array element the number would have to be reset to 1. That should work.</description>
		<content:encoded><![CDATA[<p>Hi Ang</p>
<p>You could set up two arrays and modify the code so that a pair of ads displays together each time. </p>
<p>Example: </p>
<p>$bannerAd1[1] = &#8216;code for ad 1 for banner 1&#8242;;<br />
$bannerAd2[1] = &#8216;code for ad 1 for banner 2&#8242;;</p>
<p>You cannot force it to loop through a series of ads in a sequential order unless you use a database or some way to keep track of a number that is incremented as each ad is displayed. That would be cumbersome. </p>
<p>It may be possible to do this with a cookie so that a user picks up the cookie and sees the first ad, then when the next page is loaded the number is incremented and they see the second ad and so on. When they reach the last array element the number would have to be reset to 1. That should work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ang</title>
		<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/comment-page-1/#comment-23917</link>
		<dc:creator>Ang</dc:creator>
		<pubDate>Wed, 25 Jan 2012 12:41:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/#comment-23917</guid>
		<description>I&#039;ve been using this for a few years and it works SUPER! I&#039;d now like the right 250x250 banners and the left 120x600 banners to rotate together and match.

Any suggestions for how to change the random function to loop through 1,2,3,4,etc as I have a separate php page for each one is the sidebar.php and the other single.php

Thanks!</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been using this for a few years and it works SUPER! I&#8217;d now like the right 250&#215;250 banners and the left 120&#215;600 banners to rotate together and match.</p>
<p>Any suggestions for how to change the random function to loop through 1,2,3,4,etc as I have a separate php page for each one is the sidebar.php and the other single.php</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/comment-page-1/#comment-23834</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 29 Nov 2011 13:10:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/#comment-23834</guid>
		<description>Thank you so much. This is great ad rotator I have been trying to figure out how to do something like this for a long time. I&#039;m so glad I found this. Thanks again.</description>
		<content:encoded><![CDATA[<p>Thank you so much. This is great ad rotator I have been trying to figure out how to do something like this for a long time. I&#8217;m so glad I found this. Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Accountant List</title>
		<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/comment-page-1/#comment-23617</link>
		<dc:creator>Accountant List</dc:creator>
		<pubDate>Thu, 13 Oct 2011 14:58:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/#comment-23617</guid>
		<description>This was exactly what I was looking for to rotate ads on a site with a huge number of pages.  Having the same ad in the same spot on every page loses its effectiveness.  Thank you!!</description>
		<content:encoded><![CDATA[<p>This was exactly what I was looking for to rotate ads on a site with a huge number of pages.  Having the same ad in the same spot on every page loses its effectiveness.  Thank you!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dariel</title>
		<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/comment-page-1/#comment-22645</link>
		<dc:creator>dariel</dc:creator>
		<pubDate>Thu, 18 Aug 2011 22:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/#comment-22645</guid>
		<description>That Simple script but powerfull.
Thanks for sharing this scripts this scripts work with every way. swf, images, event adsenses.
great scripts</description>
		<content:encoded><![CDATA[<p>That Simple script but powerfull.<br />
Thanks for sharing this scripts this scripts work with every way. swf, images, event adsenses.<br />
great scripts</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/comment-page-1/#comment-21732</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Tue, 26 Apr 2011 20:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/#comment-21732</guid>
		<description>I&#039;m using this script to display text. If you need to use single quotes in your text, for example as apostrophes, you can &quot;escape&quot; them by putting a \ right in front of them. Like this: Mom\&#039;s homemade pie.</description>
		<content:encoded><![CDATA[<p>I&#8217;m using this script to display text. If you need to use single quotes in your text, for example as apostrophes, you can &#8220;escape&#8221; them by putting a \ right in front of them. Like this: Mom\&#8217;s homemade pie.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael R</title>
		<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/comment-page-1/#comment-21325</link>
		<dc:creator>Michael R</dc:creator>
		<pubDate>Fri, 31 Dec 2010 04:35:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/#comment-21325</guid>
		<description>Excellent script!  Very helpful, indeed...</description>
		<content:encoded><![CDATA[<p>Excellent script!  Very helpful, indeed&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/comment-page-1/#comment-21292</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Sun, 05 Dec 2010 11:43:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/#comment-21292</guid>
		<description>EXCELLENT and SIMPLE script!!!  almost too easy. :-)  Much easier than the others I have been playing with. I have it rotating both images and flash files with no problems at all. 

Thank you.</description>
		<content:encoded><![CDATA[<p>EXCELLENT and SIMPLE script!!!  almost too easy. <img src='http://www.tech-evangelist.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   Much easier than the others I have been playing with. I have it rotating both images and flash files with no problems at all. </p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Distractedthinking</title>
		<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/comment-page-1/#comment-12497</link>
		<dc:creator>Distractedthinking</dc:creator>
		<pubDate>Wed, 27 Jan 2010 11:08:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/#comment-12497</guid>
		<description>cool script, it is working cool with jpg and swf... thanks a lot</description>
		<content:encoded><![CDATA[<p>cool script, it is working cool with jpg and swf&#8230; thanks a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ncube digital</title>
		<link>http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/comment-page-1/#comment-12204</link>
		<dc:creator>ncube digital</dc:creator>
		<pubDate>Mon, 07 Dec 2009 18:00:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.tech-evangelist.com/2007/08/03/php-banner-ad-script/#comment-12204</guid>
		<description>I am in the process of building a website and wanted a database driven php random banner rotator. this served a good purpose so i thought i would publish a simple addition in order to make it database driven. hopefully this will help anyone who wants to build on this nice snippet from TE.

php script is as follows;

//include database connection details
include(&quot;includes/connect.php&quot;);

mysql_connect($dbhost, $dblogin, $dbpass);

@mysql_select_db($db) or die(&#039;Could not select db&#039;);
$result = mysql_query(&quot;SELECT * FROM test&quot;) or die(0);

while ($row = mysql_fetch_array($result)){
$bannerAd[] = $row[&#039;bannerimg&#039;];
}

$adCount = count($bannerAd)-1;
//the -1 here serves to avoid a blank image. in my test the db had 3 records, the script sees 3 within the array but as the array starts from 0 the value of 3 in the array creates a blank image.

$randomAdNumber = mt_rand(0, $adCount);
//the 0 rather than 1 here is similar to the above so that the first record in the db shows up. if this is set as 1 then it will not read the 0 (first) value in the array

echo $bannerAd[$randomAdNumber];

The code blocks are contained within the db records.

I&#039;ll check back here every few days incase of any questions.</description>
		<content:encoded><![CDATA[<p>I am in the process of building a website and wanted a database driven php random banner rotator. this served a good purpose so i thought i would publish a simple addition in order to make it database driven. hopefully this will help anyone who wants to build on this nice snippet from TE.</p>
<p>php script is as follows;</p>
<p>//include database connection details<br />
include(&#8220;includes/connect.php&#8221;);</p>
<p>mysql_connect($dbhost, $dblogin, $dbpass);</p>
<p>@mysql_select_db($db) or die(&#8216;Could not select db&#8217;);<br />
$result = mysql_query(&#8220;SELECT * FROM test&#8221;) or die(0);</p>
<p>while ($row = mysql_fetch_array($result)){<br />
$bannerAd[] = $row['bannerimg'];<br />
}</p>
<p>$adCount = count($bannerAd)-1;<br />
//the -1 here serves to avoid a blank image. in my test the db had 3 records, the script sees 3 within the array but as the array starts from 0 the value of 3 in the array creates a blank image.</p>
<p>$randomAdNumber = mt_rand(0, $adCount);<br />
//the 0 rather than 1 here is similar to the above so that the first record in the db shows up. if this is set as 1 then it will not read the 0 (first) value in the array</p>
<p>echo $bannerAd[$randomAdNumber];</p>
<p>The code blocks are contained within the db records.</p>
<p>I&#8217;ll check back here every few days incase of any questions.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

