How to use mysql fetch array in PHP
In this article I am going to explain about mysql_fetch_array function in PHP.
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
<html>
<body>
<?php
$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 />";
}
mysql_close($con);
?>
</body>
</html>
|
Output:

You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here