top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

What are the differences among PHP functions mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

+2 votes
46 views
What are the differences among PHP functions mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
posted Mar 15, 2017 by Sahana

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

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";
}

answer Jul 20, 2017 by Vipin
0 votes

Mysql_fetch_array Fetch a result row as an associative array, a numeric array, or both.

mysql_fetch_object ( resource result ) Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows.

mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

answer Dec 26, 2017 by Jdk
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...