pkirsch Posted February 6, 2007 Share Posted February 6, 2007 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! Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 6, 2007 Share Posted February 6, 2007 have a table called ratings, with an id field, a question field, an up field and a down field. then when the person votes Thumbs Up or Thumbs Down just update that question, by using the id. so update either the up or down field with +1. make sense? Quote Link to comment Share on other sites More sharing options...
pkirsch Posted February 6, 2007 Author Share Posted February 6, 2007 Thanks! 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! Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 6, 2007 Share Posted February 6, 2007 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? Quote Link to comment Share on other sites More sharing options...
pkirsch Posted February 6, 2007 Author Share Posted February 6, 2007 Hey thanks again! Yeah! duh 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! Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 6, 2007 Share Posted February 6, 2007 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. Quote Link to comment Share on other sites More sharing options...
pkirsch Posted February 6, 2007 Author Share Posted February 6, 2007 Thanks! you have been extreamly helpful! Have a wonderful day! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.