$sql = "SELECT Lastname, Age FROM Persons ORDER BY Lastname"; $result = $mysqli -> query($sql); while ($row = $result -> fetch_row()) { //statements }