What is the difference between mysql_fetch_object and
mysql_fetch_array?
Answer Posted / rupal
mysql_fetch_row ::Return row as aan enumrated array and each
line contain a unique ID .example.
$result=mysql_query($query);
while($row=mysql_fetch_row($result))
{
print $row[0] ;
print $row[1] ;
print $row[2] ;
}
mysql_fetch_array ::Return row as anassociative or an
enumrated array or both which is default .you can refer to
outputs as databases fieldname rather then number .example.
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
print $row['name'] ;
print $row['address'] ;
print $row['city'] ;
}
mysql_fetch_object :: it return as an object on the place of
array.
$result=mysql_query($query);
while($row=mysql_fetch_object($result))
{
print $row->name ;
print $row->address ;
print $row->city ;
}
| Is This Answer Correct ? | 18 Yes | 1 No |
Post New Answer View All Answers
What is difference between readonly and constant?
What are php applications?
Explain about require and include function?
What is inheritance in php?
Is it more secure to use cookies to trfer session ids?
How to set session.gc_maxlifetime properly?
How to find datatype of variable in php?
What is symfony php?
How to send email using php script?
What is the difference between mysqli_fetch_object() and mysqli_fetch_array()?
Can constructor be private in php?
Why does php need server?
What are super global variables in php?
What is magic quotes?
Can we embedded directly PHP code into XHTML document? State Whether True or False?