technorazzi Posted December 3, 2006 Share Posted December 3, 2006 Hello - I am trying to build a voting system that is tied to a database, where users with unique ids can only vote once. Seeing as users could vote for a variety of items, would I need to build an array of some kind to hold 'voted items' and check against it?I have read that I can store the ip address of users too - but my issue is that I have a bunch of items on one page that people could vote for - so not sure how cookies would work here.other ideas?Thanks! Link to comment https://forums.phpfreaks.com/topic/29320-vote-sytem-mysql-only-vote-once/ Share on other sites More sharing options...
ataria Posted December 3, 2006 Share Posted December 3, 2006 Make a table named 'votes'then, do a query.likeselect * from votes where id=$userid..or something like that.then, num_row it.and do.if ($num_rows == '1') {youy already voted...}else {}etcetc. Link to comment https://forums.phpfreaks.com/topic/29320-vote-sytem-mysql-only-vote-once/#findComment-134453 Share on other sites More sharing options...
keeB Posted December 3, 2006 Share Posted December 3, 2006 ataria, I think he's got that idea down, it's more of people being able to vote on different things, but 1 time.Here's my solution.2 Tables for voting:First, we need a table to store all of the available votes Table votes column voteID column vote_descriptioncolumn status (is it open for voting, closed for voting,?)Table userVotescolumn voteIDcolumn userIDcolumn vote_option --> this is what they chose as the answer to the VOTEThen, you would use standard SQL to get a wealth of information..[code]select * from votes vinner join userVotes uv on uv.voteid = v.voteid where u.voteid = 2[/code]This would get all of the information about people who voted on the second item up for voting, as well as their responses.If you would like any more help with this idea, feel free to respond here, PM, whatever.- Keeb Link to comment https://forums.phpfreaks.com/topic/29320-vote-sytem-mysql-only-vote-once/#findComment-134480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.