Re: Using two colomns of mysql data as key/value pairs in arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Devon" <omicron9@comcast.net>


> I have been scouring the online documentation and experimenting for 
> hours trying to find a solution. I just can't do it.
> 
> I have two colomns of data that I am retrieving from MySQL:
> 
>    SELECT id, name FROM a_table;
> 
> I just cannot figure out how to get that data from the resource handle 
> into an associative array with the 'id' colomn making up the keys and 
> the 'name' colomn making up the values.

while($r = mysql_fetch_assoc($result))
{ $array[$r['id']] = $r['name']; }

---John Holmes...

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux