MySQL Question regarding efficiency.
Posted 07 August 2006 - 06:57 AM
pollname pollnumber ................ votedby
so and so.. 45345 ................ john34,bill44,joe,brandon366,
and code such as:(psuedo)
if $myusername."," is located in votedby
don't allow voting
Be the most efficient way of keeping track of the users who voted on it and preventing them from doing it again?
How would you do it?
Posted 07 August 2006 - 07:20 AM
poll_id - user - voted_option
23 Corbin blue
27 Fred greeen
and so on... but thats not very efficient at all... I cant think of any other way to do it that would be more efficient though...
Posted 07 August 2006 - 07:27 AM
The poll's row where "votedby" is going to be pulled from the database to show the poll anyway, so would it be more efficient to do a "find $username with comma after it in the votedby string" or a
select * where user = $username and pollnumber = $pollnumber
Posted 07 August 2006 - 07:34 AM
I would create two tables one polls, with all the poll data , and the other votes
I would then have in the votes table
username or user_id
Then before I posted a vote I would search the table like this
"SELECT COUNT(*) as `vote_match` FROM `votes` WHERE `poll_id` = '$poll_id' AND `username` = '$username'"
Hope that helps,
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users