marklarah Posted March 14, 2010 Share Posted March 14, 2010 So I'm building a thumbs up/thumbs down rating system, and for the most part it's working. The fields in the table is either -1 or 1 for an up or down, and it counts it all to get the final rating, using this: $query="SELECT SUM(rating) AS `total` from votes WHERE sid='$num'"; $result=mysql_query($query); $total=mysql_result($result,0,"total"); where $total will obviously be the final rating. How would I get the number of rows that it counted, so it could say something like Rating: 23, with 48 votes or something? thanks mark Quote Link to comment Share on other sites More sharing options...
marklarah Posted March 14, 2010 Author Share Posted March 14, 2010 Wait never mind $query="SELECT SUM(rating) AS `total` , COUNT(rating) AS `nums` from votes WHERE sid='$num'"; $result=mysql_query($query); $total=mysql_result($result,0,"total"); $nums=mysql_result($result,0,"nums"); works. thanks! 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.