Adam Voigt wrote:
>$query = mysql_query("SELECT SUM(cost) AS total FROM cart WHERE
>userid='$_SESSION[userid]';");
>
Yes, I'd missed that the OP mentioned mysql in the subject, thus there SUM.
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/un
Maybe I don't understand what your asking but if you just want
one column totalled. Why not just do it in SQL?
Example:
$query = mysql_query("SELECT SUM(cost) AS total FROM cart WHERE
userid='$_SESSION[userid]';");
$array = mysql_fetch_array($query);
This would give you the total amount of this
Jay wrote:
>I have created a table which has a column called cost. How do I add up all
>the numerical data in the cost column and display that on a webpage?
>
Go through each record and add up the value of the cost column. Your
question is so general it difficult to give more than a general poin
3 matches
Mail list logo