Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
mysql_fetch_object() and mysql_fetch_array() Functions
What is the difference between mysql_fetch_object() and mysql_fetch_array() functions in PHP?
✍: FYIcenter
mysql_fetch_object() fetches the current row of data from the query result associated with the specified result identifier. The row is returned as an object. See the example code:
<?php
$result = mysql_query("select * from fyiUser");
while ($row = mysql_fetch_object($result)) {
echo $row->user_id;
echo $row->fullname;
}
mysql_free_result($result);
?>
mysql_fetch_array() fetches the current row of data from the query result associated with the specified result identifier. The row is returned as an array with 3 options: an associative array, a numeric array, or both. The default behavior of mysql_fetch_array() is to return the row as an associative array and a numeric array. See the example code:
<?php
$result = mysql_query("select * from fyiUser");
while ($row = mysql_fetch_array($result)) {
printf ("ID: %s Name: %s", $row[0], $row["name"]);
}
mysql_free_result($result);
?>
2007-02-27, 7490👍, 0💬
Popular Posts:
What is the main difference between a Vector and an ArrayList? Java Vector class is internally synch...
What Is the Difference between Formal Parameters and Actual Parameters? - Oracle DBA FAQ - Creating ...
How To Run a JUnit Test Class? A JUnit test class usually contains a number of test methods. You can...
What is Native Image Generator (Ngen.exe)? The Native Image Generator utility (Ngen.exe) allows you ...
Describe in detail Basic of SAO architecture of Remoting? For these types of questions interviewer e...