Re: php mysql array question
| From: | Rob Adams | Date: | Fri, 11 Jul 2003 17:44:04 +0000 |
| Subject: | Re: php mysql array question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-154912@lists.php.net to get a copy of this message | ||
It shouldn't take a lot of code to put results into an array:
$query = "select * from table";
$r = mysql_result($query);
while ($row = mysql_fetch_object($r))
$hold[] = $row;
(OR, to index by some id field in the database:)
$hold[$row->id] = $row;
mysql_free_result($r);
Total of 5 lines.
-- Rob
"Larry Brown" <larry.brown@dimensionnetworks.com> wrote in message
news:CBECIONKKLMDDCIKHALJAECJIAAA.larry.brown@dimensionnetworks.com...
> Is there any php function to pull a query into an array? I know there is
a
> way to get the first row of the results in an array, but I'm having to
loop
> through each row pushing the row onto an array to get the result I'm
looking
> for and it seems like a lot of code for something that I would think is
used
> a lot.
>
> Larry S. Brown
> Dimension Networks, Inc.
> (727) 723-8388
>
>