File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between mysql_fetch_array() and mysql_fetch_row()

 
Deepthi Tanguturi
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difference between mysql_fetch_array() and mysql_fetch_row()
 
Nick Charles
Ranch Hand
Posts: 71
Linux PHP Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mysql_fetch_row is the same as mysql_fetch_array with MYSQL_NUM. That is, you get an array with a numeric index.

However, with mysql_fetch_array you can also specify MYSQL_ASSOC, in which case the array is indexed by the column names. And then there is MYSQL_BOTH where you can use either a numeric or column name index.

Using the links Matthew provide, look at how the examples differ for the two functions.
 
John David Peter
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mysql_fetch_array(): It return values both an associative and numeric array
example:
<table>
<th>Game_ID</th><th>Category</th><th>Title</th>
<?php
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('new') or die(mysql_error());
$query=mysql_query('select * from table1') or die(mysql_error());
while($res=mysql_fetch_array($query, MYSQL_NUM))
{
echo'<tr><td>'.$res[0].'</td><td>'.$res[1].'</td><td>'.$res[2].'</td></tr>';
}
echo'<table>';
?>


Reference:mysql_fetch_array

mysql_fetch_row():
It return values as numeric array
example:
<table>
<th>Game_ID</th><th>Category</th><th>Title</th>
<?php
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('new') or die(mysql_error());
$query=mysql_query('select * from table1') or die(mysql_error());
while($res=mysql_fetch_row($query))
{
echo'<tr><td>'.$res[0].'</td><td>'.$res[1].'</td><td>'.$res[2].'</td></tr>';
}
echo'<table>';
?>


Reference:mysql_fetch_row
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic