Re: MySQL result to Associative array
| From: | Rick Emery | Date: | Mon, 21 Oct 2002 13:47:45 +0000 |
| Subject: | Re: MySQL result to Associative array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120727@lists.php.net to get a copy of this message | ||
Can you: echo $myarray[1];
that is, no quotes around 1?
----- Original Message -----
From: "Tony Crockford" <tonyc@boldfish.co.uk>
To: "Php-General@Lists. Php. Net" <php-general@lists.php.net>
Sent: Monday, October 21, 2002 8:43 AM
Subject: [PHP] MySQL result to Associative array
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php