creating an array in a while loop
| From: | hentis at twilyt dot com | Date: | Mon, 16 Oct 2000 11:21:02 +0000 |
| Subject: | creating an array in a while loop | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-20338@lists.php.net to get a copy of this message | ||
hi all
I've been trying to get around this for a while now .. but I seem to be stumped.
I have a result from a query .. which I can fetch into an array as normal
I want to creat an array with selected fields from the result. something like this.
$result=mysql_query($query);
while ($row=mysql_fetch_array($result)){
$key=$row["element1"];
$value=$row["element2"];
$endarray[$key]=$value;
}
I dont't knwo how to do this .. in code .. bu i have a general idea of creating an empty array
with numrows as size
and then add each key/val pair in .. but I'm noot sure how to do it ..
can somebody please lend a hand
HEnti