query("SELECT id, firstname, lastname FROM Players WHERE lastname like '".$last."%' LIMIT $start , $size"); $player_list = null; while ($row = $result->fetch_array(MYSQL_ASSOC)) { $player = null; foreach ($row as $field) { $player[] = $field; } $player_list[] = $player; } echo json_encode($player_list); // Free resultset $result->close(); // Closing connection $db->close(); ?>