Re: Pulling two field from mysql table into an array
| From: | Toby Irmer | Date: | Mon, 02 Feb 2004 08:20:26 +0000 |
| Subject: | Re: Pulling two field from mysql table into an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176563@lists.php.net to get a copy of this message | ||
How 'bout
<?
$query = " SELECT field_name, user_id FROM table";
$result = mysql_query($query);
while($line = mysql_fetch_assoc($result)
{
$array[$line["user_id"]] = $line["field_name"];
}
?>
----- Original Message -----
From: "Richard Kurth" <rdkurth@directphp.com>
To: "Richard Kurth" <php-general@lists.php.net>
Sent: Monday, February 02, 2004 7:00 AM
Subject: [PHP] Pulling two field from mysql table into an array
>
> What is the best way to pull two fields from a mysql database and add
> the two fields to an array for each record in the table
> field_name user_id
>
> I need it so iI can access the array with $key and $value
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>