Re: Query result to an array
| From: | Zak Greant | Date: | Wed, 11 Sep 2002 20:44:48 +0000 |
| Subject: | Re: Query result to an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-116027@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On September 11, 2002 14:12, Christian Ista wrote:
> Hello,
>
> A query return x rows, by rows there are 4 fields. I'd like to put the
> result in an array, a 2 dimensions array. Could you tell me how to do
> that ?
Something like this may work for you:
# Connect to db, make query, etc.
while( $temp = mysql_fetch_row($mysql_result_handle) ) {
$array[] = array(
'key0' = array(
'keya' => $temp[0],
'keyb' => $temp[1],
),
'key1' = array(
'keya' => $temp[2],
'keyb' => $temp[3],
)
);
}
Good luck!
- --zak
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9f6tAb6QONwsK8bIRAvjKAJwKN0yvbGaztQzZOKYiy22FMqQ5EgCeP3AH
4sGpVTTX6gUJp8fZJ8xXEfQ=
=eaeg
-----END PGP SIGNATURE-----