March 23rd, 2000, 11:41 AM
Hello. I am trying to develop a banner ad rotator on my site. I DO NOT need to know the precise number of ads served per banner.
Therefore, I do not want phpAds as it would be overkill and slow down my site.
I have 3 banner spaces per page. Currently, I have 4 different sponsors. I just wanted to run a random number mechanism so that every tme the page is requested, 3 out of the available 4 banners are chosen automatically. So my current doe (pusedo) is something like this:
Is this the best way? I do not see his method as being very scalable as it requires me to manually input the possible combinations. I only need a simple solution that is scalable to many sponsors but since I do NOT need to know exact impression levels (all sponsors divide up the impressions equally), I do not want to use MYSQL to "kill a fly with hammer."
March 24th, 2000, 10:20 AM
I don't have the time to actually solve your problem, but it goes something like this:
1. Create an array of n objects (n being the number of banners. At first you can just enter an the number manually. When you learn a little more about PHP's file and directory functions, you can get PHP to simply read the number of banner graphics in your banners directory.)
2. For x = 0 to n call banner[n] (See PHP's documentation on for loops)
3. Then randomize the output of banner[n]
March 24th, 2000, 01:27 PM
Thanks for your reply. So to my understanding, you are suggestion the following:
array(...) // n objects
where would the random go? Inside the for loop? But would this allow two banners from the same sponsor to be chosen in the same loop? The key is that once a banner is chosen, it must be not chosen again in the loop. Also, in this case, there are n=4 sponsor banners, but I only want to display 3 banners at a time. With the for loop, would not this display 4 banners after a run?
April 25th, 2000, 07:19 AM
Here's some code I use for a Pwd generator :
that basically lifts a digit from the srting which then gets done 8 times to make an 8-=digit PW...
if you number the banners ban000 ban001 ban002 etc etc .. you can use a similar string-based idea and then do:
print "<img src="$banname">";
which would put the appropriate numbered banner in there
GE @ Obsidian Software