RE: Mysql Variable Displayed in php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:  Mysql Variable Displayed in php
> 
> 
> RE:  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();
> 
> ?>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux