Forum Moderators: coopster

Message Too Old, No Replies

One vote per person, how?

Have one vote per person per article

         

supermember

11:14 pm on Oct 25, 2005 (gmt 0)



Hi all,

I have a site built around a database.

There are articles in this database which I want the users to be able to rate, the trouble is I only want them to be able to rate each guide once.

Everyone must login to vote, but what is the best way to do it with several hundred articles to rate on?

Making sure they login before voting and the rating code itself works fine, I just need help on how to stop the same person voting twice.

Any ideas?

Thank you

Netter

11:33 pm on Oct 25, 2005 (gmt 0)

10+ Year Member



make another table i.e. votes with columns:
artID,
usrID,
vote

And each time the user votes do something like
$result=mysql_query("select artID from votes where userID=$userid and artID=$articleid");
if(mysql_num_rows($result)) echo "Cheater!";
else { mysql_query("insert into votes values($articleid,$userid,$vote)"); echo "Done!"; }

just 3 lines ;)

supermember

11:36 pm on Oct 25, 2005 (gmt 0)



Thanks a lot, I have been thinking about this all day!

Amazing what a fresh set of eyes can do :)

Thank you again

supermember

2:56 am on Oct 26, 2005 (gmt 0)



Just replying to say thanks.
Have added the code into it now, and with a bit of tweaking it works great.

Thanks a lot, you have saved a lot of hassle!

Netter

7:14 am on Oct 26, 2005 (gmt 0)

10+ Year Member



you're welcome