mysql_fetch_array()

It returns a row from a recordset as an associative array and/or a numeric array

MySQL table – Users

+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
|  2 | JS   |
|  3 | HTML |
|  4 | AS   |
+—-+——+

Example

<?php
mysql_connect(“localhost”, “root”, “password”) or die(mysql_error());
mysql_select_db(“database_name”);
echo “<pre>”;
$userQry = mysql_query(“SELECT * FROM users”);
while($userInfo = mysql_fetch_array($userQry)){
print_r($userInfo);
}
?>

Output

Array
(
[0] => 1
[id] => 1
[1] => PHP
[name] => PHP
)
Array
(
[0] => 2
[id] => 2
[1] => JS
[name] => JS
)
Array
(
[0] => 3
[id] => 3
[1] => HTML
[name] => HTML
)
Array
(
[0] => 4
[id] => 4
[1] => AS
[name] => AS
)