1) PHP and MySQL Code:
PHP Code:
<?php
// Make a MySQL Connection
$query = "SELECT type, COUNT(fieldname) FROM tablename GROUP BY type";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "There are ". $row['COUNT(fieldname)'] ." ". $row['type'] ." items.";
echo "<br />";
}
?>
2) PHP and MySQL Code:
PHP Code:
<?php
// Make a MySQL Connection
$query = "SELECT type, SUM(fieldname) FROM tablename GROUP BY fieldname";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "Total ". $row['fieldname']. " = $". $row['SUM(fieldname)'];
echo "<br />";
}
?>