===== Syntax =====
array mysql_fetch_array(resource $res [, int $resulttype])
//(PHP 4, PHP 5)//
^ $res | The database result returned by a call to [[mysql_query]]. |
^ $resulttype | The type of array the function should return. |
^ RETURNS | The array representing the next row in the result set, or **false** when the recordset is empty or no more records can be retrieved. |
**Possible Values for $resulttype**
^ MYSQL_ASSOC | Associative, keys are the field names |
^ MYSQL_NUM | Numeric array, keys are indexes 0 .. (fields - 1) |
^ MYSQL_BOTH | The default - both key types are part of the result array |
===== What it Does =====
The function **mysql_fetch_assoc** is used to retrieve a single row of a result set. You should call this function repeatedly to get successive rows in a single result set. When you reach the end of the recordset, the function will return **false**.
===== Example =====
// open a connection
$res = mysql_connect($server, $user, $pass);
// fetch all of the states
$data = mysql_query('SELECT * FROM tblState', $res);
while ($row = mysql_fetch_assoc($data)) {
echo $row['statename'] . '
';
}