...

View Full Version : Sum quantities



pavmoxo
08-30-2006, 10:08 AM
Greetings!!!

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??

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

first link:

http://www.tizag.com/mysqlTutorial/mysqlsum.php

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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum