Maybe I don't understand what your asking but if you just want
one column totalled. Why not just do it in SQL?
$query = mysql_query("SELECT SUM(cost) AS total FROM cart WHERE
$array = mysql_fetch_array($query);
This would give you the total amount of this user's cost from there
shopping cart (just an example). So, you would just print $array[total]
and poof. No having to loop or anything.
On Tue, 2002-07-16 at 12:07, Chris Hewitt wrote:
> 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 pointer.
> What I would do is:
> 1. Start off an html page upto the point you want to display the data.
> 2. Do a sql select statement to get all the records.
> 3. Loop through all the records, adding up the cost column.
> 4. Display the result on the html page.
> 5. Finish up of the html page.
> I'm not sure what you are expecting in the way of an answer here but to
> do this you need knowledge of HTML, SQL, a database and a programming
> language suitable for generating web pages (e.g. PHP).
> Hope this helps.
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php