Results 1 to 3 of 3
Thread: dividing two colummes
Aug 8, 2003, 13:05 #1
- Join Date
- Jun 2002
- 0 Post(s)
- 0 Thread(s)
dividing two columns
Ok I am trying to setup a rating system where people can rate new articles on my site. I have setup two columns rank (the total of all the ratings) and numrates (the number of times the article has been rated. I want to have a page that displays the top five highest rated articles. Can someone please tell me what the problem is and how to fix it?
$queryresult = mysql_query("SELECT id, name, (rank/numerates) AS sqlthisrank FROM atts WHERE type=$indextype ORDER BY sqlthisrank LIMIT 5" );
Last edited by Zero G; Aug 8, 2003 at 13:18.
Aug 8, 2003, 15:55 #2
NO! You tell us what the problem is (your error message) and we'll tell you how to fix it
Anyway, to get the top highest rated articles you don't need to divide by the number of ratings, this will give you the articles with the highest average ratings.
Does MySQL do computed columns? Anyway you probably need to ORDER BY sqlthisrank DESC
Aug 8, 2003, 15:56 #3
And you say the column is called numrates but you are using numerates in the select....