At 23:19 -0600 1/25/02, [EMAIL PROTECTED] wrote:
>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].

You're selecting a column named "sum(value)" not "value" or "sum".
$myrow[0] should give you the value you're looking for.  Or modify your
query to add a column alias, and use the alias name:

$result = mysql_query("SELECT sum(value) AS the_sum FROM pets",$db);
                         $myrow = mysql_fetch_array($result);
         print "$myrow[the_sum]";

>How can I get the sum displayed?
>Thanks in advance,
>PHP Database Mailing List (
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]

PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to