Re: php mysql array question

Posted: 07-11-2003, 03:48 PM
I use the PEAR db http://pear.php.net/manual/en/package.database.php

This returns arrays - examples here
http://pear.php.net/manual/en/packag...ntro-fetch.php

look at the Quick data retreaval down the page

pete


Larry Brown wrote:
> 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
>
>
Reply With Quote

Responses to "Re: php mysql array question"

Rob Adams
Guest
Posts: n/a
 
Re: php mysql array question
Posted: 07-11-2003, 05:44 PM
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@dime nsionnetworks.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
>
>

Reply With Quote
 
LinkBack Thread Tools Search this Thread Display Modes
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Array question webhead_1 Coldfusion - Getting Started 31 11-23-2003 03:26 PM
MySQL Table Question > Array? Sixii PHP Development 2 10-05-2003 09:50 PM
Sort Array Question... Andrew Durstewitz ASP 3 07-16-2003 07:49 PM
[PHP] php mysql array question Cpt John W. Holmes PHP Development 1 07-11-2003 03:25 PM
note 33659 added to function.mysql-fetch-array Markus@rack1.php.net PHP Notes 0 07-03-2003 10:36 AM