Jump to content

[SOLVED] product rating scripts (thumbs up or down)


pkirsch

Recommended Posts

What is the best method to make a rating script similar to a "rate this product...thumbs up or thumbs down"  type system for a logged-in user, which will append to some compiling DB? (for example, if 100 people rate a specific product, the DB can report 83 liked, 17 disliked)?

 

Thanks all!

Link to comment
Share on other sites

:D Thanks!  :D

 

I have another question that relates to my voting system!

 

I would like to make it so that when (other registered users) vote for a user, (who must be logged in for authentication) that once the user reaches a certain amount of points, they will have access to a certain page! but ONLY then!

 

I would like to make different levels of users, and each level has different privileges! the levels need to be dynamic! so voting can change then! (both + and - directions).

 

Any idea on how i could go about this?

 

p.s how can i make a .php file so that it can NOT be seen if you go directly to it in a browser, but it can still function!

 

These forums are the most wonderful and helpful community in the world!

Thanks SO much!

 

Link to comment
Share on other sites

any php script that dosnt have html will display blank, even though it is running in the background.

 

now for that question. i just guess you could add a new row to your user table saying votes then just update that when people vote for them. and what do you mean by the user who is getting the votes must be logged in for authentication?

Link to comment
Share on other sites

:) Hey thanks again!

 

Yeah! duh  ;D i should have noticed that when i tried to open a .php file in firefox (that had only php) it kept asking me to open it in dreamweaver! Hah!

 

What i mean is i am trying to make a system in which a user could be rated by other users (who must be logged in to vote.)  users vote for each other (if they want) using the thumbs up/down and try to maintain a score! when the users reach a certain score (which fluxuates, depending on the other users votes (up or down) they will be able to have access to a page (only if their score is over "x", and only if their logged in.)

Now the only dilemma i have is; i need a way to prevent over voting, so if you have any ideas, please let me know!

Link to comment
Share on other sites

well like i said before. so in your users table have a votes row.

then create a new table called user_votes or something. it will have 3 fields, id, user_id, voter_id. then when the user votes for the user update the users vote number to the correct amount. then insert some new data into the user_votes section.

 

$userid = $_SESSION['id']; //the id of the voting user.
$voting_id = $_POST['voting_id']; //the id of the user receiving the votes.
$vote = $_POST['vote']; //the variable containing either up/down. from a select box.

if($vote == "up"){
$sign = "+"; //set the sign to +
}else{
$sign = "-"; //set the sign to -
}

if(mysql_num_rows(mysql_query("SELECT * FROM user_votes WHERE `voted_id`='{$userid}' AND `user_id`='{$voting_id}'")) == 1){
echo "You have already voted on this user.";
}else{

mysql_query("UPDATE `users` SET `votes`=(votes{$sign}1) WHERE `id`='{$voting_id}'");
mysql_query("INSERT INTO `user_votes` (`user_id`,`voter_id`) VALUES ('{$voting_id}','{$userid}')");
echo "Vote has been cast.";

}

 

hope that code can be a base for you. good luck.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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