$qry = "SELECT id, name FROM a_table";
   $result = mysql_query($qry) or die(mysql_error());
   while ($rs = mysql_fetch_row($result)) {
      $myarray[$rs[0]] = $rs[1];
   }

   is that waht you need?

   hth
   Jeff




                                                                                       
                                                 
                      Devon                                                            
                                                 
                      <[EMAIL PROTECTED]        To:       [EMAIL PROTECTED]            
                                               
                      .net>                    cc:                                     
                                                 
                                               Subject:  [PHP-DB] Using two colomns of 
mysql data as key/value pairs in arrays          
                      10/20/2003 09:30                                                 
                                                 
                      AM                                                               
                                                 
                                                                                       
                                                 
                                                                                       
                                                 




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.

Any help would be wonderful! :)



Using PHP 4.3.3 on Linux if it matters.

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

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

Reply via email to