blacko Posted June 28, 2008 Share Posted June 28, 2008 Hi, I found this really useful script to randomize content without showing the same thing twice: http://www.php-scripts.com/20051212/72/ You can see a working example here: http://www.xnova.com.ar/negro/randomizer.php This scripts uses a cookie so that the number is not repeated, but I need this same script to work with a server side txt file or database. I have tried a couple of things and failed. What i basically need is to rotate ads, so that they all show the same amount of times. Can somebody give me a hand? Thanks in advance!! Quote Link to comment https://forums.phpfreaks.com/topic/112345-randomize-without-repeat/ Share on other sites More sharing options...
.josh Posted June 28, 2008 Share Posted June 28, 2008 I think the first question I would ask is, are these ads supposed to be uniquely rotated to random visitors, or are they uniquely rotated to 'members' who are 'logged in' ? Quote Link to comment https://forums.phpfreaks.com/topic/112345-randomize-without-repeat/#findComment-576883 Share on other sites More sharing options...
blacko Posted June 28, 2008 Author Share Posted June 28, 2008 Thanks for you answer! This would be for all the visitors. I'm trying to duplicate the script using a txt file with fread and fwrite, instead of the session cookie, but I've had no luck so far. The problem with regular random ad script, is that ad impressions have lots of differences between the ads. I think I'm going to create another script that counts the views for each ad, and show the ad that has less views. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/112345-randomize-without-repeat/#findComment-576914 Share on other sites More sharing options...
.josh Posted June 28, 2008 Share Posted June 28, 2008 Okay the next question I would ask is, what's wrong with using the cookie? Worried that someone might not allow cookies? You can pass the session id through the url or through hidden fields in a form as an alternative. Failing that, you can setup a temp file or temp db entries using the user's ip address to identify them. Failing that, you can use javascript to keep track of it. The trick here is not really making it cycle through your ads without repeating: it's keeping the user uniquely identified so you can cycle through your ads. Quote Link to comment https://forums.phpfreaks.com/topic/112345-randomize-without-repeat/#findComment-576920 Share on other sites More sharing options...
blacko Posted June 28, 2008 Author Share Posted June 28, 2008 Hmmm... I think i did not explained myself ok I finally got to this: http://www.xnova.com.ar/negro/test2.php What I wanted was to show each ad the exact same amount of times (or with 1 view of difference). If I just used a cookie, there would have been differences on the total view counts. Now that I got this, I can use a cookie so that i only count unique users, and not each pageview. I think that's it, I'll come back if I have more questions Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/112345-randomize-without-repeat/#findComment-576963 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.