while($row = mysql_fetch_array($id,MYSQL_ASSOC)) {
foreach($row as $index=>$value) {
$z[$index][] = $value;
}
}
For a table with 3 rows and fields abc and def in each row this would
produce an array like this:
$z[abc][0]
$z[def][0]
$z[abc][1]
$z[def][1]
$z[abc][2]
$z[def][2]
-Rasmus
On Sat, 20 Jan 2001, Jeff Lacy wrote:
> 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;
> }
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]