I'm trying to get an array from a server class and processed to the client. The problem is that im only recieving the first result from the database? I don't know how to get all the results from the database into the array and I would like to have a loop on the client side that goes through the array.
Database class:
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;
}
Session class:
function getPlayers($teamid) {
global $database;
$players = $database->getPlayers ( $teamid );
return $players;
}
Client class:
$players = $session->getPlayers($session->teamid);
while (list($key, $value) = each($players)) {
echo "Key: $key; Value: $value<br />\n";
}
Thanks in advance for your time.