unemployment Posted February 15, 2011 Share Posted February 15, 2011 I'd like to be able to echo out the count of all of the conversations_ids. I'd prefer to do the counting in MySQL The column looks something like Conversation ID's 1 1 1 2 3 3 5 5 5 5 $sql = "SELECT `pm_messages`.`conversation_id` AS `id` FROM `pm_messages` WHERE `pm_messages`.`conversation_id` = ${conversation['id']} GROUP BY `pm_messages`.`conversation_id`"; $result = mysql_query($sql); $replies = mysql_fetch_assoc($result); echo count($replies['id']); In this case when ${conversation['id']} = 1 I want $replies to echo out 3 Link to comment https://forums.phpfreaks.com/topic/227789-count-group/ Share on other sites More sharing options...
Maq Posted February 15, 2011 Share Posted February 15, 2011 You already have the GROUP BY, just COUNT the number of conversation_id's. Link to comment https://forums.phpfreaks.com/topic/227789-count-group/#findComment-1174668 Share on other sites More sharing options...
PFMaBiSmAd Posted February 15, 2011 Share Posted February 15, 2011 In your original thread for this problem, the reply that was posted showed you how to get a count in the (each) group. Link to comment https://forums.phpfreaks.com/topic/227789-count-group/#findComment-1174669 Share on other sites More sharing options...
Maq Posted February 15, 2011 Share Posted February 15, 2011 In your original thread for this problem, the reply that was posted showed you how to get a count in the (each) group. Forgot about that, I replied in that thread too ;/ Here is the duplicate: http://www.phpfreaks.com/forums/php-coding-help/total-unique-id%27s-with-php-and-mysql/msg1527852/#msg1527852 Link to comment https://forums.phpfreaks.com/topic/227789-count-group/#findComment-1174672 Share on other sites More sharing options...
Recommended Posts