How to use mysql fetch array in PHP

In this article I am going to explain about mysql_fetch_array function in PHP.
  • 1847

PHP mysql_fetch_array() Function

The PHP mysql_fetch_array function returns a row from a recordset as an associative array or a numeric array or both.

Syntax of mysql_fetch_array function

mysql_fetch_array(data, arrayType)

Parameters in
mysql_fetch_array  function

It have two parameter:

Parameter Description
data It specifies to data pointer to use.
arrayType It specifies the type of array to fetch.

Example of mysql_fetch_array function




$con = mysql_connect("localhost","gupta","sharad");

if (!$con)


  die('Could not connect: ' . mysql_error());


mysql_select_db("Mcn_Solution", $con);

$result = mysql_query("SELECT * FROM Emp");

while($row = mysql_fetch_array($result))


  echo $row['Fname'] . " " . $row['LastName'] . " ". $row['Id'];

  echo "<br />";








You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.