Home » Labs » Usage of PHP mysql_fetch_array() Function Example  

Usage of PHP mysql_fetch_array() Function Example


Filed under Labs

The mysql_fetch_array() in PHP allows you to retrieve data from mysql_query. IT always returns the first row in a MySQL Resource in the form of an associative/ numeric array.

Syntax

<?php
mysql_fetch_array(data,array_type)
?>

Example

<?php
// Your Connection Code here
 
$query = "SELECT * FROM Demo_Table"; 
 
$result = mysql_query($query) or die(mysql_error());
 
$row = mysql_fetch_array($result) or die(mysql_error());
echo $row['name']. " - ". $row['age'];
?>

The output will be: James Shadow – 33

Posts you may like: