banner system

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
basdog22
Forum Contributor
Posts: 158
Joined: Sun Nov 30, 2003 3:03 pm
Location: Greece

banner system

Post by basdog22 »

Need help here:

Is there a way that i create a random script that the results will be category depended?

What i mean is:
I want to make a script that will display random banners but not so random... For example:
A customer "customerA" has subsdribed in the banner system at category "1" and another one "customerB" at category "2". CustomerA must have his banner displayed more often than customerB. Lets say 10/10 displays for customerA and 9/10 displays for customerB.

How could i do this?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Well, there are various ways. The first I thought of is that you could store the 'hits' of a certain banner somewhere (preferably database).
By using those hits, you can recreate your own statistics and make the banners visible based on that.

The below is just a quick example of something that might give you more ideas. Hope it's understandable enough.

Code: Select all

<pre>
<?php
    $one = 15;
    $two = 8;
    $total = $one+$two;
    // show percentage (roughly)
    echo round($one / $total * 100);
    echo '<br>';
    echo round($two / $total * 100);

    echo '<hr>';

    if ($one < 66) { $one++; } // increase the value of banner1...
    else { $two++; } // ...or banner two.

    // re-display the result
    $total = $one+$two;
    echo round($one / $total * 100);
    echo '<br>';
    echo round($two / $total * 100);
?>

Code: Select all

65
35
---
67
33
basdog22
Forum Contributor
Posts: 158
Joined: Sun Nov 30, 2003 3:03 pm
Location: Greece

Post by basdog22 »

Say i have 5 image holders to put 10 banners...

1-3 banners are category 1(pay more)
4-8 banners are category 2(<1)
9-10 banners are category 3(<2)

a script to display random banners but with respect to those that pay more??? :wink: :wink: :wink:
Post Reply