我正在尝试从服务器类获取数组并处理到客户端。问题是我只收到数据库的第一个结果?我不知道如何将数据库中的所有结果都放入数组中,我希望在客户端有一个循环通过数组。
数据库类:
function getPlayers($teamid) {
$q = "SELECT * FROM view_players WHERE teamid = '$teamid'";
$result = mysqli_query ( $this->connection, $q );
/* Error occurred, return given name by default */
if (! $result || (mysqli_num_rows ( $result ) < 1)) {
return NULL;
}
/* Return result array */
$dbarray = mysqli_fetch_array ( $result );
return $dbarray;
}
会话班:
function getPlayers($teamid) {
global $database;
$players = $database->getPlayers ( $teamid );
return $players;
}
客户端类:
$players = $session->getPlayers($session->teamid);
while (list($key, $value) = each($players)) {
echo "Key: $key; Value: $value<br />\n";
}
提前感谢您的时间。