> Is there a better way to do this in PHP? It seems that a single number > (key) and single name (value) would lend itself perfectly to an (indexed > or associative) array. I would think there is some PHP API call that I'm > unaware of that will just take the whole result set and stuff it into an > array for me no? If not, there should be. Perfect for things like > ListBoxes, or table lookups so you don't have to hit the database > constantly with joins et. al. > > $sql = "SELECT id, name FROM mytable ORDER BY id"; > if ( !($result = mysql_query($sql,$link)) ) { echo "failed\n"; } > while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) > $myarray[$row['id']] = $row['name'];
That's the way to do it. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php