Hey guys, Just wondering if any of you know a way of creating a banner rotator that has no repeats..? Well, its a number rotator in my case and the number represents the name of an image. Is there any way in which I can have one code 10 times on one page, the same code and for there to be no repeats. Like maybe at the top of the page can be all the variables and stuff and the repeated 10 times below an outcome... I am not extremely good at PHP, but I can edit easily, just not create. Any help would be greatly appreciated, even if what I need is not PHP. Thanks.
Even a paid one? OIOpublisher has the function to rotate banners and will not show same banner at one time.
No, all I am looking for is the rotator, no ads, no purchases, no complicated script, just a simple rotator that does not repeat itself. Thank you for the suggestion though.
I can build you one, based off a card/deck idea I had... Draw from the deck, use next each time and dont repeat, when empty show nothing.. Did you want admin panel to add/remove, or just in the script? What features would you like? Such as: Insert url, image, title and thats it - flash ads, etc.. -Josh
Probably the easiest way would be to fill a folder/directory full of files named after your banner names, then glob/unlink files as they're used. bannerator.php <?php // "banners" will be a folder full of "*.banner" files $banners = glob('banners/*.banner'); // If the folder was empty, there will be no banner if(isset($banners[0])) { $banner = $banners[floor(lcg_value() * count($banners))]; unlink($banner); $banner = str_replace('.banner', '', $banner); printf('<a href="./site?id=%1$s"><img src="./banner%1$s.png"/></a>', $banner); } ?> Code (markup): index.php <html> ... <?php include "bannerator.php"; ?> ... <?php include "bannerator.php" ?> Code (markup):
Thank you joebert, just one problem, I found out that it deletes the files once they are used, which is not too good... Is there any way to remove the 'unlink' bit but still not have any repeats? Thank you very much, and if you can help Acecool, that would be great!
An alternative would be to rename the files to "xxx.used" and have a cron job running every X minutes that renames everything back to "xxx.banner" when it can't find any *.banner files. <?php // "banners" will be a folder full of "*.banner" files $banners = glob('banners/*.banner'); // If the folder was empty, there will be no banner if(isset($banners[0])) { $banner = $banners[floor(lcg_value() * count($banners))]; rename($banner, "$banner.used"); $banner = str_replace('.banner', '', $banner); printf('<a href="./site?id=%1$s"><img src="./banner%1$s.png"/></a>', $banner); } ?> Code (markup): Then cron would execute something like this every X minutes depending on how fast your stock depletes. <?php $banners = glob('/path/to/banners/*.banner'); if(empty($banners[0])) { foreach(glob('/path/to/banners/*.used') as $used) { rename($used, str_replace('.banner.used', '.banner', $used)); } } ?> Code (markup): Or, that cron job could even just be the fail condition to the first block of code.
Thank you loads, it took a lot of changing and testing, but I got it to work, basically, when the page loads, the images show and then get named .used at end and then at the end of the page they are renamed .png again lol, thank you very much joe, +rep coming your way Thanks again everybody!