Jump to content

Best method for this?


joecooper

Recommended Posts

Ill try explain it as best i can.

 

My script is for a traffic exhange system.

 

I have 2 tables, one is users (ID, UID and CREDITS)

The other is links(ID,UID, LINK)

 

UID is the User's ID.

 

My script currently chooses a random user from users, and then chooses a random link from links (from that user), and then forwards the person running the script to that link.

 

The problem is, I need to limit the amount of times one user can visit a link to 3 times max.

 

Im not sure how to go about this. Do i add another feild on "links", with a list of all the users IDs'? and then parse this to check if they are on it 3 times?

 

Thanks

 

Joe

Link to comment
Share on other sites

You'll need yet another table, using the link ID as the key.

So you'll have

ID, LINKID, UID, viewCount

 

just addon to viewCount when they click the link... and deauthorize if it's greater than 3

 

Ah thats spot on! So my code will choose a random UID, Then choose random link, and then check if that link has been selected already 3 times, if it has, choose another.

 

Only problem, is i can see this being a problem if there is loads of links, it may take a while with many querys to find one that is less than 3. plus, if they are all more than 3, then it would be stuck in a loop. Any method around this?

Link to comment
Share on other sites

Only problem, is i can see this being a problem if there is loads of links, it may take a while with many querys to find one that is less than 3. plus, if they are all more than 3, then it would be stuck in a loop. Any method around this?

Talk to fenway, this could easily be alleviated with a few JOINs... at least I believe

Link to comment
Share on other sites

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.