I have worked a little with associative arrays but seems like there should be a quicker way.
Looked at the MySQL dos about SUM() & GROUP BY() but I didn't realy get, so perhaps I am a little slow.
Tried many variation of the following tests without any luck !
could use a few hints !!
$result = mysql_query("select Tax, SUM(Tax) from taxes GROUP BY State");
// $result = mysql_query("select Tax, from taxes GROUP BY State and SUM(Tax)");
// $result = mysql_query("select SUM(Tax) from taxes GROUP BY State");
while($row=mysql_fetch_array($result,MYSQL_ASSOC)) {
$j=mysql_num_fields($result);
for($i=0;$i<$j;$i++) {
$k=mysql_field_name($result,$i);
$$k=$row[$k];
}
echo "$State : $SubTotal, $Tax, $TotalCost, $SUM<BR>";
}
Thanks,
Peter