php-db | 2001072
Date: 07/16/01
- Next message: Joachim Steinhauser: "[PHP-DB] PHP + unixODBC"
- Previous message: Tom Hodder: "RE: [PHP-DB] NEXT - PREVIOUS coding"
- In reply to: Tom Hodder: "RE: [PHP-DB] NEXT - PREVIOUS coding"
- Next in thread: Manuel Lemos: "[PHP-DB] Re: NEXT - PREVIOUS coding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Joachim Steinhauser: "[PHP-DB] PHP + unixODBC"
- Previous message: Tom Hodder: "RE: [PHP-DB] NEXT - PREVIOUS coding"
- In reply to: Tom Hodder: "RE: [PHP-DB] NEXT - PREVIOUS coding"
- Next in thread: Manuel Lemos: "[PHP-DB] Re: NEXT - PREVIOUS coding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

