when
$query = 'SELECT * FROM users';
and there are multiple columns/rows, does mysql_fetch_assoc($result)
return a two-dimensional array?
Can I draw each row by simply saying: array_pop(mysql_fetch_assoc($r))
thanks!
when
$query = 'SELECT * FROM users';
and there are multiple columns/rows, does mysql_fetch_assoc($result)
return a two-dimensional array?
Can I draw each row by simply saying: array_pop(mysql_fetch_assoc($r))
thanks!
No, it returns a single row.
Calling it again will return the next row, until there are no more rows.
You can build a multi-dimensional array like this:
$rows = array();
while ($row = mysql_fetch_assoc($data))
$rows[] = $row;
*mysql_fetch_assoc* returns an associative array (an array with the selected column names as keys), one row at a time until there are no more rows in the result of the query. Call it in a loop to work with a row at a time:
while ($row = mysql_fetch_assoc($result)) {
echo $row["username"];
echo $row["email"];
}
(Assuming username and email are columns in the users table).
array_pop will unset the first value of the array and return it, so in your case your first table field would be unset.