Jump to content

Count Group


unemployment

Recommended Posts

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
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.