rating system problem
Moderator: General Moderators
rating system problem
I have the next problem.
I have a cd review database. Registered people should be able to rate the reviewed cd's (values from 1 to 10). But how do I check to see if they have rated this cd already?
I think it has something to do with putting their username in the database record of the current cd?
Any help appreciated!
I have a cd review database. Registered people should be able to rate the reviewed cd's (values from 1 to 10). But how do I check to see if they have rated this cd already?
I think it has something to do with putting their username in the database record of the current cd?
Any help appreciated!
it depends on the type of your id.
It might be an idea to use just one field and keep adding ID's into it. That way it can grow and grow. Im not sure whether there is a limit to the length of a field.
Example (if IDs are int);
Name: Pink Floyd
IDs: 1, 34, 67, 543, 54,
The IDs field keeps being added to. You could then get the string and search through it looking for the ID.
Lawrence
It might be an idea to use just one field and keep adding ID's into it. That way it can grow and grow. Im not sure whether there is a limit to the length of a field.
Example (if IDs are int);
Name: Pink Floyd
IDs: 1, 34, 67, 543, 54,
The IDs field keeps being added to. You could then get the string and search through it looking for the ID.
Lawrence
If many people vote on the CD's this could cause your database to become much bigger. I would suggest just setting a cookie on the user's machine and this will stop most people from voting again although you can get around it. You can just save something like the ID or the name of the CD in the cookie and then check if that specific cookie is set before letting a user vote again.
More info on Cookies:
http://www.php.net/set_cookie
More info on Cookies:
http://www.php.net/set_cookie
I personally would make a new table called cd_votes. Then within the table have voteID, userID, cdID, and timestamp for columns.
Then at the voting page, I would query the cd_votes table for a vote with a cdID the same ID as the CD being viewed and the same userID as the current user viewing the page. If a match exists he/she has voted. If not then display a voting area, since this means they have not voted.
If it makes sense it's a good solution.
Then at the voting page, I would query the cd_votes table for a vote with a cdID the same ID as the CD being viewed and the same userID as the current user viewing the page. If a match exists he/she has voted. If not then display a voting area, since this means they have not voted.
If it makes sense it's a good solution.
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
This isn't the lottery, just a simple cd rating. I don't think people would be that determined to create a new account for that extra vote. heh
This ties the vote with their account rather than with their browser. If the user logs in with Mozilla insead of IE, they can revote. If the user deletes cookies, they can revote. If they use another computer, they can revote.
Not to disregard the usefulness of cookies in general, in this particular case I think they are a second resort to the above method.
This ties the vote with their account rather than with their browser. If the user logs in with Mozilla insead of IE, they can revote. If the user deletes cookies, they can revote. If they use another computer, they can revote.
Not to disregard the usefulness of cookies in general, in this particular case I think they are a second resort to the above method.