Help with PHP/SQL query.
Posted: Mon Jan 11, 2010 8:50 am
I am trying to get a count of the number of times the same road appears for one steward so if there are 4 of the same road for "steward A" it will show "the Road" and "4".
I thought the code below was correct but not getting any count back the the road?
Please please help.
PS. 'DB' instead of 'MYSQL' is valid as using a CMS "Drupal"
I thought the code below was correct but not getting any count back the the road?
Please please help.
PS. 'DB' instead of 'MYSQL' is valid as using a CMS "Drupal"
Code: Select all
<?PHP
$result = DB_query("SELECT field_steward_value,field_road_name_value,COUNT(field_road_name_value) AS Volume FROM content_type_resident GROUP BY field_steward_value,field_road_name_value");
echo "<table border='1'>
<tr>
<th>Steward Name</th>
<th>Roads Looked After</th>
<th>count</th>
</tr>";
while($row = DB_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['field_steward_value'] . "</td>";
echo "<td>" . $row['field_road_name_value'] . "</td>";
echo "<td>" . $row[$result->Volume] . "</td>";
echo "</tr>";
}
echo "</table>";
?>