I just made a quick little script with SQL query. Now when I go to phpmyadmin and execute
SELECT name FROM players WHERE online='1' ORDER BY name ASC
It outputs the desired players ( 0TheMonk, Player, Veeve )
But with PHP:
$query=mysql_query("SELECT name FROM players WHERE online='1' ORDER BY name ASC");
$query_array=mysql_fetch_array($query);
echo implode(',',$query_array);
It echoes: 0TheMonk,0TheMonk
Instead of: 0TheMonk,Player,Veeve
It always outputs the first player in the array, twice. What am I doing wrong? Thanks in advance.
mysql_*
functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. – Kermit Mar 18 '13 at 19:48mysql_fetch_array
only returns one row. See the docs: php.net/mysql_fetch_array – Rocket Hazmat Mar 18 '13 at 19:55