我知道这可能会很愚蠢,但我很沮丧没有找到解决方案。我去:我有一个包含玩家的表,我想将玩家存储到一个数组中,如下所示:
Array ( [0] => player1 [1] => player2 [2] => player3)
现在我从下面的代码中得到的是:
Array ( [0] => Array ( [player] => player1 ) [1] => Array ( [player] => player2 ) [2] => Array ( [player] => player3 ))
因此,我将这个额外的层放入名为“player”的数组中,这是我从中选择的列字段的名称。如何调整我的代码?
$query_players="SELECT player FROM `whiteboard_games` WHERE id='$id'";
$result = mysql_query($query_players) or die;
$players = array();
while($row = mysql_fetch_assoc($result))
{ $players[] = $row; }
非常感谢!