Odp: [PHP4BETA] re:Totalling a variable in a while loop
| From: | Lukasz Felsztukier | Date: | Mon, 21 Feb 2000 23:51:35 +0000 |
| Subject: | Odp: [PHP4BETA] re:Totalling a variable in a while loop | ||
| References: | 1 2 3 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-10614@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: Joseph H Blythe <joe.blythe@binarylogic.com.au>
To: <huntsman@www.nisu.flinders.edu.au>; <php4beta@lists.php.net>
Sent: Tuesday, February 22, 2000 12:43 AM
Subject: Re: [PHP4BETA] re:Totalling a variable in a while loop
> This works as a straight MYSQL command
>
> SELECT SUM(ItemTotal) AS grandTotal FROM Items WHERE
> UserID='cc2b438a843e93612ea3a4d5936ee547';
>
> But I think the problem might lie in the alias or something how do I access it
> through php $grand_total? It returns ""
Query is one thing - php variables is quite another ;-)
Just do the following:
$result = mysql_query("SELECT SUM(ItemTotal) FROM Items WHERE
UserID='cc2b438a843e93612ea3a4d5936ee547'");
list($grand_total) = mysql_fetch_row($result);
Now you'll have your thingy in the variable
cheers mate,
Lukasz