valdet
03-26-2009, 08:32 AM
Hi there
In one site I currently have a simple banner rotating system, which enables different sponsors to have their banner shown.
I was using this in a simple plugin on parse_templates hook
$random_numbers = rand(1, 5);
$banner[1] = '<a href=" http://www.somesite1.com (http://www.somesite.com/)"><img src="http://www.mysite.com/image1.jpg" alt="First message" border="0" /></a>';
$banner[2] = '<a href=" http://www.somesite2.com (http://www.somesite.com/)"><img src="http://www.mysite.com/image2.jpg (http://www.mysite.com/image1.jpg)" alt="Second message" border="0" /></a>';
$banner[3] = '<a href=" http://www.somesite3.com (http://www.somesite.com/)"><img src="http://www.mysite.com/image3.jpg (http://www.mysite.com/image1.jpg)" alt="Third message" border="0" /></a>';
$banner[4] = '<a href=" http://www.somesite4.com (http://www.somesite.com/)"><img src="http://www.mysite.com/image4.jpg (http://www.mysite.com/image1.jpg)" alt="Fourth message" border="0" /></a>';
$banner[5] = '<a href=" http://www.somesite5.com (http://www.somesite.com/)"><img src="http://www.mysite.com/image5.jpg (http://www.mysite.com/image1.jpg)" alt="Fifth message" border="0" /></a>';
and I use this code to call that function in my header template
$banner[$random_numbers]
As you see the banners were displayed in completely random order.
After some time, few sponsors are complaining that they see other banners more than they see theirs. Common complaints you know. :)
Since my solution is simple and straightforward, I decided that I will make a slight change by displaying the banners in ordered/consecutive display, like 1 2 3 4 5 and not random like now 3 1 4 2 5 3 3 2 5 1 etc....
I did some research and came upon different resources for PHP codes to display them.
Here are few:
<?php
$counter = 1;
while ($counter <= 12) {
echo $counter;
$counter++;
}
?><?php
function counter($y,$x)
{
$counter = $y;
while ($counter <= $x) {
echo $counter;
$counter++;
}}
counter(1,9)
?>
while ($i <= 5){
$banner[$i] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
$i++;}
Can you please show me in simple terms how would I go about displaying my banners in looped ordered manner like this:
image1.jpg
image2.jpg
image3.jpg
image4.jpg
image5.jpg
image1.jpg
image2.jpg
image3.jpg
. . .
. . .
. . .
Thanks and I look forward to your replies.
--------------- Added 1238075409 at 1238075409 ---------------
I found a tip elsewhere, but the banners are not displaying at all
function counter($y,$x)
{
$counter = $y;
while ($counter <= $x) {
$counter++;
}}
$ordered_numbers = counter(1, 5);
$banner[1] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
$banner[2] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
$banner[3] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
$banner[4] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
$banner[5] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
I used this code in my header template
$banner[$ordered_numbers]
I tried the above as single plugin and came up with errors
Then I declared function counter($y,$x) as separate plugin in global_start hook with the rest of the code in another plugin, but this thing is not showing up.
I am sure something rather simple is missing from here.
Can someone please take a quick look and let me know what needs to be done so banners are displayed in consecutive order.
I know this may sound weird because when there are many users the display will still look to you as random, but at least each banner gets equal impressions.
Thanks
In one site I currently have a simple banner rotating system, which enables different sponsors to have their banner shown.
I was using this in a simple plugin on parse_templates hook
$random_numbers = rand(1, 5);
$banner[1] = '<a href=" http://www.somesite1.com (http://www.somesite.com/)"><img src="http://www.mysite.com/image1.jpg" alt="First message" border="0" /></a>';
$banner[2] = '<a href=" http://www.somesite2.com (http://www.somesite.com/)"><img src="http://www.mysite.com/image2.jpg (http://www.mysite.com/image1.jpg)" alt="Second message" border="0" /></a>';
$banner[3] = '<a href=" http://www.somesite3.com (http://www.somesite.com/)"><img src="http://www.mysite.com/image3.jpg (http://www.mysite.com/image1.jpg)" alt="Third message" border="0" /></a>';
$banner[4] = '<a href=" http://www.somesite4.com (http://www.somesite.com/)"><img src="http://www.mysite.com/image4.jpg (http://www.mysite.com/image1.jpg)" alt="Fourth message" border="0" /></a>';
$banner[5] = '<a href=" http://www.somesite5.com (http://www.somesite.com/)"><img src="http://www.mysite.com/image5.jpg (http://www.mysite.com/image1.jpg)" alt="Fifth message" border="0" /></a>';
and I use this code to call that function in my header template
$banner[$random_numbers]
As you see the banners were displayed in completely random order.
After some time, few sponsors are complaining that they see other banners more than they see theirs. Common complaints you know. :)
Since my solution is simple and straightforward, I decided that I will make a slight change by displaying the banners in ordered/consecutive display, like 1 2 3 4 5 and not random like now 3 1 4 2 5 3 3 2 5 1 etc....
I did some research and came upon different resources for PHP codes to display them.
Here are few:
<?php
$counter = 1;
while ($counter <= 12) {
echo $counter;
$counter++;
}
?><?php
function counter($y,$x)
{
$counter = $y;
while ($counter <= $x) {
echo $counter;
$counter++;
}}
counter(1,9)
?>
while ($i <= 5){
$banner[$i] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
$i++;}
Can you please show me in simple terms how would I go about displaying my banners in looped ordered manner like this:
image1.jpg
image2.jpg
image3.jpg
image4.jpg
image5.jpg
image1.jpg
image2.jpg
image3.jpg
. . .
. . .
. . .
Thanks and I look forward to your replies.
--------------- Added 1238075409 at 1238075409 ---------------
I found a tip elsewhere, but the banners are not displaying at all
function counter($y,$x)
{
$counter = $y;
while ($counter <= $x) {
$counter++;
}}
$ordered_numbers = counter(1, 5);
$banner[1] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
$banner[2] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
$banner[3] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
$banner[4] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
$banner[5] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>';
I used this code in my header template
$banner[$ordered_numbers]
I tried the above as single plugin and came up with errors
Then I declared function counter($y,$x) as separate plugin in global_start hook with the rest of the code in another plugin, but this thing is not showing up.
I am sure something rather simple is missing from here.
Can someone please take a quick look and let me know what needs to be done so banners are displayed in consecutive order.
I know this may sound weird because when there are many users the display will still look to you as random, but at least each banner gets equal impressions.
Thanks