Hi,

I'm looking for a way to rotate my banner ads randomly or even in order, just some sort of rotation. I don't need anything else, like stats, I just want them to change every time the page is loaded, can anyone help me out on how to do this?

Thanks

    I would suggest on using PhpMyAds
    Its very VERY good,it probably has too much features that you dont need.. but its pretty good.

      Another way to attack this problem is by creating a table which contains the href/ad code.

      Use the MYSQL rand() function when selecting from the query. To read info on the rand function, see Mathematical functions (about half way down). You will also want to look at limit.

      ...From version 3.23 you can do: SELECT * FROM table_name ORDER BY RAND()...

      This will be a better option than using the text file if you might want to be able to have control over the ads. Doing things like selecting types of ads by genre, bias or doing things like expiring old ads etc. All this is possible with text files, but no where near as easy.

        If you don't want to use a text file, and you don't want to use mySQL, and if you are using PHP 4:

        srand ((float) microtime() * 10000000);
        $banner_urls = array (
            "banner1.jpg",
            "banner2.jpg",
            "/advertisements/bork.gif",
            "you_get_the_idea.png");
        $index = array_rand ($banner_urls, 1);
        echo "<img src=/"" . $banner_urls[$index] . "/">";
        
        

        HTH

          Write a Reply...