Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 5th, 2006, 05:53 PM
Authorized User
 
Join Date: Oct 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default 'Feedback' Scoring system

Hi

I am trying to create a feedback section of a website and trying to get the feedback scoring system working like this:

If a user receives a positive feedback then the users score increases by 1.
If the user receives a neutral feedback then it has no effect on the users score.
If a user gets a negative feedback then the users score is subtracted by 1.

All easy so far, but how do I only allow separate users to have an impact of only 1 on the users score, ie if the customer has 2 positive feedbacks then the customers score will only rise by 1.

It is basically the system Ebay uses I am trying to replicate and a description is here of the system http://pages.ebay.co.uk/help/feedbac...ck-scores.html

But how am I going to create the query to only ever effect a users score by 1? Here is what I have so far, but it will only get the sum of the users score but not take into account the 'distinct' element I need from the 'from_username' column:

SELECT sum(feedback_score)
FROM feedback
WHERE feedback.to_username=thisuser

I have tried this:

SELECT DISTINCT(from_username)
FROM feedback
WHERE feedback.to_username=thisuser

that gets the distinct usernames from the table, but how do I combine the 2 queries to get the desired result?

Sorry for the length of the post

TIA
David
 
Old October 24th, 2006, 05:33 PM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Add LIMIT 1 to the end?

--
Don't Stand on your head - you'll get footprints in your hair
                                           http://charlieharvey.org.uk
                                              http://charlieharvey.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Student feedback system..help dhanuka ASP.NET 2.0 Basics 1 July 28th, 2007 05:11 AM
Concern and feedback picnn Intro Programming 1 October 30th, 2006 02:36 PM
feedback into email alitoday Classic ASP Databases 3 August 2nd, 2004 06:07 AM
ASP Feedback Ben Horne Classic ASP Basics 2 November 21st, 2003 11:30 AM
Feedback- not support. Hal Levy Wrox Book Feedback 0 July 4th, 2003 10:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.