Try something like this (UNTESTED)
// array1 is temporary array
// array2 is the one to fill with query results
$array1= array("URL"=>"nul","URLN"=>"nul");
$array2= array(
1=>array("URL"=>"","URLN" => "")
);
// $n is counter of registers
// begin mysql query
// foreach element
// $row[0] is URL
// $row[1] is URLN
if ($n==0) {
$array2[1]["URL"] = $row[0];
$array2[1]["URLN"] = $row[1];
} else
{
$array2[1]["URL"] = $row[0];
$array2[1]["URLN"] = $row[1];
array_push ($array2,$array1[1]);
}
// end foreach
// Example
// $array2[10]["URL"] now contains the 10th URL value
// $array2[10]["URLN"] now contains the 10th URLN value
----- Original Message -----
From: "Tony Devlin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 22, 2004 3:04 PM
Subject: [PHP-WIN] MySQL query to generate Array
How do you setup a mysql query to generate an array?
I want to take URL and URLName from a database and use it to create an array
called links.
I know how to do the array and the mysql seperately, I don't know how to
make the results of
the mysql become the key=>value pairs in the array.
Any help is appreciated
--Tony
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php