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.
--
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/package.database.db.intro-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 arra
On Fri, 11 Jul 2003, CPT John W. Holmes 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
> >
> 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
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 i
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]
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
7 matches
Mail list logo