Jump to content

Recommended Posts

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!!

Link to comment
https://forums.phpfreaks.com/topic/112345-randomize-without-repeat/
Share on other sites

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

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. 

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 :D

Thanks for your help!

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.