$sql = "SELECT Lastname, Age FROM Persons ORDER BY Lastname"; $result = mysqli_query($con, $sql); /*MYSQLI_ASSOC MYSQLI_NUM (this is default) MYSQLI_BOTH */ // Fetch all mysqli_fetch_all($result, MYSQLI_ASSOC);