The mysql_fetch_object() function is used to get a row in the object form from the record set.
PHP mysql_fetch_object() Function Example:
The mysql_fetch_object() function is used to get a row in the object form from the record set. The mysql_fetch_object() function returns a row in object form from record set.
Syntax:
mysql_fetch_object(data)
Example:
<?php $connection = mysql_connect("localhost","root","root"); if (!$connection) { die('PHP Mysql database connection could not connect : ' . mysql_error()); } else{ mysql_select_db("php_mysql", $connection); $sql = "SELECT * from user"; $result = mysql_query($sql,$connection); while ($row = mysql_fetch_object($result)) { echo $row->user_name . "<br />"; echo $row->user_email . "<br /><br />"; } } mysql_close($connection); ?>
The database 'user' table records is:
After running this example the browser output is:
Output:
Deepak deepak@rediffmail.com Dipali dipali@hotmail.com
[ 0 ] Comments