Mysql & Array Question
| From: | Jeff Lacy | Date: | Sat, 20 Jan 2001 21:12:39 +0000 |
| Subject: | Mysql & Array Question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-35844@lists.php.net to get a copy of this message | ||
Hello Everyone,
I am trying to make a page that will interact with mysql. I need to be
able to access the result of my mysql_query by using a for loop. I made a
little function that will sortof do this, but it returns a numeric array.
Of course, I want an associative array (becauses things get screwy with a
null). Does anyone know how to make something like what I want? Thanks a
bunch :-)
This is my current function:
function returnArray ($id) {
$z = array (array());
for ($i = 0; $row = mysql_fetch_array ($id); $i++) {
for ($a = 0; $a < sizeof ($row); $a++) {
$z[$i][$a] = $row[$a];
}
}
return $z;
}