MySQL result to Associative array

From: Date: Mon, 21 Oct 2002 13:43:09 +0000
Subject: MySQL result to Associative array
Groups: php.general 
Request: Send a blank email to php-general+get-120726@lists.php.net to get a copy of this message
Hi all how do I turn a two column table into MySQL into an Associative array? I've tried this: $md_query = "SELECT * FROM md_def order by md_ref asc"; $md_result= mysql_query($md_query) or die ("Error in query: $md_query. " . mysql_error()); while ($row = mysql_fetch_array($md_result)) { $md_ref=$row['md_ref']; $md_title=$row['md_title']; $myarray['$md_ref']=$md_title; } but I can't read out of the array like this: echo $myarray['1']; where am I going wrong? Thanks Tony

« previous php.general (#120726) next »