RE: [PHP-DB] Mysql Variable Displayed in php
| From: | Jennifer Goodie | Date: | Mon, 12 May 2003 17:54:43 +0000 |
| Subject: | RE: [PHP-DB] Mysql Variable Displayed in php | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27678@lists.php.net to get a copy of this message | ||
while ($row = mysql_fetch_row($result)) { // Begin while
echo($row[0]); //this is one way
echo($row['overall']); //this is another way
} // end while
> -----Original Message-----
> From: Delz [mailto:phpuser@modeglobal.com]
> Sent: Friday, May 09, 2003 8:38 PM
> To: php-db@lists.php.net
> Subject: [PHP-DB] Mysql Variable Displayed in php
>
>
> RE: [PHP-DB] mysql variable displayed in phpHi All,
>
> I have this following script in php connecting to a mysql
> database and declared a variable named "overall" in the mysql statement:
> How do I display the result in php generated by the mysql
> variable "overall" so I can display it in my browser. I'm new to
> php & can't
> seem to output the result. Any help will be appreciated.
>
> ############################################################
> <?
>
> $connection = mysql_connect("myhost","myuser","mypasswd");
> if (!$connection) {
> echo "Could not make a connection!";
> exit;
> }
>
> $db = mysql_select_db("mydb",$connection);
>
> if (!$db) {
> echo "Could not select database!";
> exit;
> }
>
>
> $query = "select @overalltotal :=SUM(total) as overall FROM mytable";
> $result = mysql_db_query("mydb", $query);
>
> if ($result)
> {
>
>
> while ($row = mysql_fetch_row($result)) { // Begin while
>
>
> } // end while
>
>
> } else { echo "problems...."; }
> mysql_close();
>
> ?>