On Saturday 26 January 2002 13:19, [EMAIL PROTECTED] wrote:
> Hello,
>
> I've been experimenting with adding decimal columns. From the mysql docs I
> got this SELECT sum(value) FROM pets;
>
> So I did this $result = mysql_query("SELECT sum(value) FROM pets",$db);
> $myrow = mysql_fetch_array($result);
> print "$myrow[value]";
> I also tried $myrow[sum].
>
> How can I get the sum displayed?
Try:
$result = mysql_query("SELECT sum(value) AS Total FROM pets",$db);
$myrow = mysql_fetch_array($result);
print "$myrow[Total]";
"Total" can be anything you want. You can use it to alias a column name:
SELECT a_column_with_a_very_long_name AS short_name FROM ...
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
Lonely is a man without love.
-- Englebert Humperdinck
*/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]