aspose file tools*
The moose likes PHP and the fly likes Difference between mysql_fetch_array() and mysql_fetch_row() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » PHP
Bookmark "Difference between mysql_fetch_array() and mysql_fetch_row()" Watch "Difference between mysql_fetch_array() and mysql_fetch_row()" New topic
Author

Difference between mysql_fetch_array() and mysql_fetch_row()

Deepthi Tanguturi
Greenhorn

Joined: Sep 06, 2011
Posts: 17
Difference between mysql_fetch_array() and mysql_fetch_row()
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4464
    
    8

http://www.php.net/manual/en/function.mysql-fetch-array.php

http://www.php.net/manual/en/function.mysql-fetch-row.php
Nick Charles
Ranch Hand

Joined: Oct 09, 2011
Posts: 71

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

Joined: Jun 06, 2014
Posts: 2
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
 
subject: Difference between mysql_fetch_array() and mysql_fetch_row()