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 Link to comment https://forums.phpfreaks.com/topic/195201-mysql-query-problem/ 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! Link to comment https://forums.phpfreaks.com/topic/195201-mysql-query-problem/#findComment-1025947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.