Sum array problem,

From: Date: Mon, 16 Jul 2001 11:23:22 +0000
Subject: Sum array problem,
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-10441@lists.php.net to get a copy of this message
Hi all, I am stuck on a problem and I can certainly do with some help. I want to create an array with the values of one field from a mysql database and then add all of it up. if ($numrows>0) { $i=0; while ($list = mysql_fetch_array($result)) $total[$i]=($list["price"]*$list["qty"]); echo "<TD class=\"normal\">£ ".$total[$i]."</TD>"; ++$i; } $a=array($total[0],$total[1]); echo "Total = £ ".array_sum($a)."\n"; } if I put the indexes manualy as 0,1,2 as above it works fine , my problem is that I am trying to create an array with all the values, I tried using $a=array($total[range(0,$i)]); but it gives me an ILLEGAL Offset Type. What am I doing wrong? Can anybody help. Please?????? Thanks in advance, Cami

« previous php.db (#10441) next »