>I'd like to add all values for $purchase_price that are returned, how do I
>do this?
>Here's what i have now.
><?php
>$result = mysql_query("SELECT purchase_price FROM assets where
>order_number='$order_number' ORDER BY $desc");

$total = 0;

>while(list($purchase_price) = mysql_fetch_row($result)) {

echo "$purchase_price<BR>\n";
$total += $purchase_price; # Short-hand for $total = $total +
$purchase_price;
}

>?>


Actually, it might be better to just change your SQL to:

select SUM(purchase_price) from assets where order_number = '$order_number'

The SQL SUM() will be *MUCH* faster than your while () loop.

-- 
Like Music?  http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to