Posted by mbocquet on 10/13/56 11:29
p cooper wrote:
> Sorry if this isnt the correct place- I cant find an obvious PHP/MySQL NG
>
> A 2 column table and i want row 1 to be the key and row 2 to be the value
> $result = mysql_query("SELECT * FROM table");
> while($row=mysql_fetch_row($result)){
>
> $array['$row[0]']=$row[1]
> }
> which doesnt work .
>
>
> im after the equivalent (in perl) of keys%array and values%array functions
I was just searching the way to do this and landed here.
You should replace ' by " or remove them... then it works
while ($row=mysql_fetch_row($result))
$array["$row[0]"]=$row[1];
or
$array[$row[0]]=$row[1];
print_r($array);
[Back to original message]
|