Difference Between Mysql_fetch_array And Mysql_fetch_assoc And Mysql_fetch_row
Mysql_fetch_row()
Mysql_fetch_row fetch result row an numeric way. This function return a row where the valuew will come in the order as they are defined in the query, and the keys will span from 0 to one less than the number of columns selected.
Mysql_fetch_assoc()
Fetch a result row as an associative array.This function will return a
row as an associative array where the column names will be the keys storing
corresponding value
Mysql_fetch_array()
Fetch a result row as an associative array, a numeric array and also it fetches by both associative & numeric array.This function will actually return an array with both the contents of mysql_fetch_row and mysql_fetch_assoc merged into one. It will both have numeric and string keys.
Mysql_fetch_object()
Fetch a result row as an object.
Mysql_fetch_row()
Mysql_fetch_row fetch result row an numeric way. This function return a row where the valuew will come in the order as they are defined in the query, and the keys will span from 0 to one less than the number of columns selected.
$result = mysql_query("select * from user");
while ($rows = mysql_fetch_row($result))
{
echo $rows[0];
echo "<br>";
echo $rows[1];
}Mysql_fetch_assoc()
Fetch a result row as an associative array.This function will return a
row as an associative array where the column names will be the keys storing
corresponding value
$result = mysql_query("select * from user");
while ($rows = mysql_fetch_assoc($result))
{
echo $rows['id'];
echo "<br>";
echo $rows['name'];
}
Mysql_fetch_array()
Fetch a result row as an associative array, a numeric array and also it fetches by both associative & numeric array.This function will actually return an array with both the contents of mysql_fetch_row and mysql_fetch_assoc merged into one. It will both have numeric and string keys.
$result = mysql_query("select * from user");
while ($rows = mysql_fetch_arrayc($result))
{
echo $rows['id'];
echo "<br>";
echo $rows['name'];
}
Mysql_fetch_object()
Fetch a result row as an object.
$result = mysql_query("select * from user");
while ($rows = mysql_fetch_assoc($result))
{
echo $rows->id;
echo "<br>";
echo $rows->name;
}
No comments:
Post a Comment