What is mysql fetch object in PHP

In this article I am going to explain about mysql_fetch_object function in PHP.
  • 1931

PHP mysql_fetch_object() Function

The PHP mysql_fetch_object function is used to fetch a result row as an object and it returns an object with properties that correspond to the fetched row and moves the internal data pointer forth.

Syntax of mysql_fetch_object function

mysql_fetch_object(data)

Parameters in mysql_fetch_object function

It has only one parameter:

Parameter Description
data It specifies which data pointer to use.

Example of mysql_fetch_object function

<html>

<body>

<?php

$con=mysql_connect('localhost','gupta','sharad');

if(!$con)

{

die("Could not connect:".musql_error());

}

$database=mysql_select_db("Mcn_Solution", $con);

$qry="select * from Emp";

$result=mysql_query($qry,$con);

while($rowVal=mysql_fetch_object($result))

{

echo $rowVal->Fname;

echo " ";

echo $rowVal->LastName;

echo " ";

echo $rowVal->Id."<br/>";

}

mysql_close($con);

?>

</body>

</html>


Output:

mysql-fetch-object-php.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.