Jump to content

vote sytem - mysql - only vote once


technorazzi

Recommended Posts

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

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_description
column status (is it open for voting, closed for voting,?)

Table userVotes
column voteID
column userID
column vote_option --> this is what they chose as the answer to the VOTE

Then, you would use standard SQL to get a wealth of information..

[code]select * from votes v
inner 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.