inherit
121254
0
Jun 1, 2016 7:27:22 GMT -8
atalkingfish
331
March 2008
atalkingfish
|
Post by atalkingfish on Sept 22, 2011 15:30:12 GMT -8
Hello,
I have a site at rbnstuff.com where I am testing out something I learned how to do. I am still very undeveloped, but basically I have a database full of songs (the columns are, like, id, song, artist, etc) and one of the columns is "rating", which I have made user-editable in a "like" sort of way by using php files along with the "id" of the song. I've got that all figured out and I can have different rating systems (I prefer this like thing, though) but eventually I want to have it so people can register on the site and can only upvote once.
The problem is making it so users can only upvote once. I have learned how to create a user (though I haven't been able to allow users to create themselves, I believe that I can figure that out, as I have found a tutorial on it, but any help would be grateful) but I have not found a way to restrict a user's number of votes per song.
Any help would be greatly appreciated and, since I'm knew at this, I'm sure that whoever wants to help may need more information, so feel free to ask me anything.
|
|
inherit
123128
0
Feb 3, 2020 13:53:38 GMT -8
Malagrond
Remember, remember the 5th of November.
813
April 2008
malagrond
|
Post by Malagrond on Sept 22, 2011 15:40:14 GMT -8
You could have a field for each user (probably TEXT(9999999)) which stores song id's they have voted on. Make the default value the pipe | symbol, then tack on the song id and another pipe for each vote. For example, say I vote on songs 4, 12, 395, and 33. Store it as:
|4|12|395|33|
Then use PHP regexp to match |song_id| against this field like so: (represented in JavaScript because I'm lazy)
if(uservotes.match(/\|4\|/gi))
Disable the rating button if it returns true.
I'm terrible at this stuff, but that's how I'd do it =p
|
|
inherit
121254
0
Jun 1, 2016 7:27:22 GMT -8
atalkingfish
331
March 2008
atalkingfish
|
Post by atalkingfish on Sept 22, 2011 16:54:14 GMT -8
I guess I'm gonna need a little more help than that. I'm really new at this and while I understand how to make tables and such, I've only done it a couple times and may need sort of a walk-through.
|
|
inherit
123128
0
Feb 3, 2020 13:53:38 GMT -8
Malagrond
Remember, remember the 5th of November.
813
April 2008
malagrond
|
Post by Malagrond on Sept 22, 2011 17:28:06 GMT -8
Try reading up on this page: www.php.net/manual/en/function.preg-match.phpCompare the field against a regexp that includes the id number. If it returns 0, the user can vote. As for the table, just add a new TEXT (full text) field of some ridiculous length like 9999999999 or something =p
|
|
inherit
121254
0
Jun 1, 2016 7:27:22 GMT -8
atalkingfish
331
March 2008
atalkingfish
|
Post by atalkingfish on Sept 22, 2011 17:31:26 GMT -8
How do I get the id numbers into the user's table? if you check on the site, the rate button isn't so much a button, but a link.
|
|
inherit
123128
0
Feb 3, 2020 13:53:38 GMT -8
Malagrond
Remember, remember the 5th of November.
813
April 2008
malagrond
|
Post by Malagrond on Sept 22, 2011 17:33:32 GMT -8
You have to create a new column. Use PHPMyAdmin or a remote mysql client (though you should have the first installed already; access it via your hosting control panel).
|
|
inherit
121254
0
Jun 1, 2016 7:27:22 GMT -8
atalkingfish
331
March 2008
atalkingfish
|
Post by atalkingfish on Sept 22, 2011 17:41:24 GMT -8
Well, I know how to make the new column. Sorry, I wasn't clear. When a person votes on a song, how do I get it so the song id gets put into the new column?
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Sept 22, 2011 17:46:44 GMT -8
update table_name set column_name = concat(column_name, '|ID') where user_id = 'user_id';
|
|
inherit
121254
0
Jun 1, 2016 7:27:22 GMT -8
atalkingfish
331
March 2008
atalkingfish
|
Post by atalkingfish on Sept 22, 2011 17:50:21 GMT -8
I'm sorry, but I think you guys are assuming I know way more than I do. I've literally only made a site with registration and voting and my MySQL/php knowledge does not extend past that. I would really like if someone could help me through this step by step or something. That way I can get it set up how I want and further my knowledge of this type of thing so I don't need to ask for help as often.
|
|
inherit
121254
0
Jun 1, 2016 7:27:22 GMT -8
atalkingfish
331
March 2008
atalkingfish
|
Post by atalkingfish on Sept 24, 2011 6:26:22 GMT -8
I would like to bump this because I've been trying really hard to learn this stuff, but I seem to be failing in the direction of this problem, as I have no idea how to restrict user voting to 1 per person per item. Any help would be greatly appreciated.
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Sept 25, 2011 5:59:49 GMT -8
Try reading up on this page: www.php.net/manual/en/function.preg-match.phpCompare the field against a regexp that includes the id number. If it returns 0, the user can vote. As for the table, just add a new TEXT (full text) field of some ridiculous length like 9999999999 or something =p I think explode() would be helpful in that situation. And just foreach() the array created and check to see if the value is in there.
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Sept 25, 2011 16:34:07 GMT -8
I'm sorry, but I think you guys are assuming I know way more than I do. I've literally only made a site with registration and voting and my MySQL/php knowledge does not extend past that. I would really like if someone could help me through this step by step or something. That way I can get it set up how I want and further my knowledge of this type of thing so I don't need to ask for help as often. I would like to bump this because I've been trying really hard to learn this stuff, but I seem to be failing in the direction of this problem, as I have no idea how to restrict user voting to 1 per person per item. Any help would be greatly appreciated. I'd like to point out that if you really want to do all of this it would be best if you bought a PHP book. You'll be able to learn much more quickly because it will cover all the topics that you will need to know to know. It will require some effort on your part to read the chapters and do the examples since you will also need to learn the basics of programming (if statements, loop, data types, data structures etc.), but it would be worth it. That being said, it would be easier for us if you posted your code so we can see what you have so far.
|
|
inherit
121254
0
Jun 1, 2016 7:27:22 GMT -8
atalkingfish
331
March 2008
atalkingfish
|
Post by atalkingfish on Sept 25, 2011 17:10:19 GMT -8
I've been taking time to learn this stuff over the last few days. I am getting a grasp on a lot of the basic things, but I think I'll wait until I've learned a little more before venturing into this type of stuff. Then I'll just make another thread when I'm ready and organized so I don't waste your guys' time.
|
|