-----Original Message-----
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 16, 2007 1:46 PM
To: Andras Kende
Cc: php-general@lists.php.net
Subject: RE: [PHP] mysql_fetch_array to associative array

On Mon, 2007-07-16 at 13:37 -0700, Andras Kende wrote:
> 
> Hi Rob,
> 
> Thanks for your help, its associative but I forget to mention its needs
> To be a single dimensional associative array.
> 
> 
> $result = array();
> while ( $row = mysql_fetch_assoc($get) ) {
> $result[] = $row;
> }
> 
> This creates multi dimensional like:
> 
> Array ( [0] => Array ( [0] => 3 [1] => BMW ) [1] => Array ( [0] => 1 [1]
=>
> Mercedes ) )
> 
> I tried to play with foreach and array_push but still not perfect

I'm not sure I understand... you have multiple rows being returned do
you not? How to you intend to handle them in a single level array?

Let's image the following rows are returned from the database:

    array
    (
        'title' => 'The Dragonbone Chair',
        'author' => 'Tad Williams',
    ),
    array
    (
        'title' => 'Sword of Shannarah',
        'author' => 'Terry Brooks',
    ),

Show me how you would like the final array to look and I can figure out
the code you need to organize it the way you want.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

Hi Rob,

$conn->getassoc(select id,name from cars)

I would need a single array like: (its for used with pear:quickform
dropdown)

Array ( [2] => BMW [1] => FORD )

Or:

Array ( [The Dragonbone Chair] => 'Tad Williams' [Sword of Shannarah] =>
'Terry Brooks' )


Thanks a lot,

Andras

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to