I'm trying to list the names of cities in an array on php-mysql, but when I Use these lines - & gt; ; It has 4 cities and 4 arrays but I want them Like to list Array ([0] = & gt; ISTANBUL [1] => London [2] => Paris [3] => Newer) > What should I do? Just add the city to another array: The code for your question will actually output: , you will only receive the output that the
$ sql = "Select city from the list"; $ Sorgu = mysql_query ($ sql); While ($ rs = mysql_fetch_assoc ($ sorgu)) {print_r ($ rs); } Mysql_free_result ($ sorgu); (<0) => (London) Array ([0] => PARIS) Array ([0] => OSLO)
$ Array = array (); While ($ rs = mysql_fetch_assoc ($ sorgu)) {$ array [] = $ rs ['city']; } Print_r ($ array);
array ([city] => gt; ISTANBUL) array ([city] => London) Note Array ([city] => PARIS) arrow ([city] = & gt; OSLO]
city key If you select
mysql_fetch_row () .
mysql _ * library is disliked, consider upgrading PDO or MySQLi do.
No comments:
Post a Comment