Number of Times a Value is in a Field

mkusens 09 Apr, 2011
I have created a chronoform where a drop down field has about 10 possible values. In chronoconnectivity, I created a view that will filter by the values in that field. I want to create a total at the bottom that shows the number of times a given value is in that field.

Data in database called "IntakeForm" for field "Attorney":

Michael
John
Steve
Mark
Howard
Michael
Michael
Steve

What I want to see at the bottom of the chronoconnectivity view:

Howard: 1
John: 1
Mark: 1
Michael: 3
Steve: 2

I am sure it is a quick mysql query but can't find how to do it. Thanks.
GreyHead 10 Apr, 2011
Hi mkusens,

Off the top of my head it will be something like
<?php
$db =& JFactory::getDBO();
$query = "
    SELECT COUNT(`Attorney`) AS `count`, `Attorney`
        FROM `IntakeForm`
        GROUP BY `Attorney` ;
";
$db->setQuery($query);
$data = $db->loadObjectList();
?>

Bob
This topic is locked and no more replies can be posted.