AW: [PHP] associative arrays
| From: | Martin Lucas | Date: | Thu, 12 Jul 2001 15:03:53 +0000 |
| Subject: | AW: [PHP] associative arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-57599@lists.php.net to get a copy of this message | ||
hi adrian,
many thanks for your tip. it works fine.
kind regards
martin
-----Ursprüngliche Nachricht-----
Von: Adrian Ciutureanu [mailto:adrian.ciutureanu@softure.com]
Gesendet: Donnerstag, 12. Juli 2001 15:46
An: Martin Lucas
Cc: php-general@lists.php.net
Betreff: RE: [PHP] associative arrays
$result = mysql_db_query("database","select item1, item2 from table");
while ($row = mysql_fetch_array($result)) {
$myArray[$row['item1']] = $row['item2'];
}
> -----Original Message-----
> From: Martin Lucas [mailto:martin.lucas@techconsult.de]
> Sent: 12 iulie 2001 16:25
> To: 'php-general@lists.php.net'
> Subject: [PHP] associative arrays
>
>
> Hi everybody
> i have the following database query:
>
> $result=mysql_db_query("database","select item1,item2 from table");
> while ($row=mysql_fetch_array($result)){
> $a=$row[item1];
> $b=$row[item2];
>
> }
> what i need is an associative array, with $a as key and $b as value,
> containing each item1 and item2 from the database
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
>