View Full Version : Sum quantities

08-30-2006, 11:08 AM

I have a problem that I haven't discover the solution and I need a help of you!...

I have a DB table with a quantity field that I update frequently. The table have some registers and I want to see the sum of that quantities of them.

My situation in this moment:

$sql = "select * from cart where session = '$sid'";
$query = query($sql);
$conta = mysql_num_rows($query);
for ($i=0;$i<$conta;$i++)

$arrw = mysql_fetch_array($query);


<td align="right"><h2><a href="carrinho.php" target="_blank">Carrinho</a> - tem <em><? if($arrw["quant"]) echo $arrw["quant"]; else echo "0"; ?></em> produtos</h2></td>

<? } ?>

In this case appears a number of phrases as the number of registers that I have update.

Any sugestion??

08-30-2006, 01:31 PM
google -> mysql sum

first link:


have some good examples, you will understend it.

ps: tenta googlar primeiro poupa-te tempo, em vez de esperares que aqui te deem a resposta.