mysql_fetch_row()
Fetch a result row as an numeric array
<?php
include('db.php');
$query=mysql_query("select * from tb");
$row=mysql_fetch_row($query);
echo $row[0];
echo $row[1];
echo $row[2];
?>
Result
1 tobby tobby78$2
mysql_fetch_object()
Fetch a result row as an object
<?php
include('db.php');
$query=mysql_query("select * from tb");
$row=mysql_fetch_object($query);
echo $row->id;
echo $row->username;
echo $row->password;
?>
Result
1 tobby tobby78$2
mysql_fetch_assoc()
Fetch a result row as an associative array
<?php
include('db.php');
$query=mysql_query("select * from tb");
$row=mysql_fetch_assoc($query);
echo $row['id'];
echo $row['username'];
echo $row['password'];
?>
Result
1 tobby tobby78$2
mysql_fetch_array()
Fetch a result row as an associative array, a numeric array and also it fetches by both associative & numeric array.
<?php
include('db.php');
$query=mysql_query("select * from tb");
$row=mysql_fetch_array($query);
echo $row['id'];
echo $row['username'];
echo $row['password'];
/* here both associative array and numeric array will work. */
echo $row[0];
echo $row[1];
echo $row[2];
?>