如何将MySQL查询结果用作HTML表单中的选项

<?php
$con = new mysqli('localhost', 'root' ,'', 'world');
$query = 'SELECT * FROM city ORDER BY Name';
if ($result = mysqli_query($con, $query)) {
    echo "<table>";
    while ($row = mysqli_fetch_assoc($result)) {
        echo "<tr>"
        echo "<td>" . $row['Name'] . "</td>";
        echo "<td>" . $row['CountryCode'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
    mysqli_free_result($result);
}
mysqli_close($con);
?>

This simple code will display every entries in this database. Now I would like to add a selective display option by choosing the CountryCode.

$query2 = 'SELECT DISTINCT CountryCode FROM city ORDER BY CountryCode';

How do I use the result I got from the query above and make it become radio buttons to choose what to display?

Similar to what you are doing already: Something like

while ($row = mysqli_fetch_assoc($result)) {
 echo "<input type='radio' name='whatever' value='".$row['Name']."'>". $row['Name'];
}

Ofcourse the field names can be whatever you like them to be, as long as you select them in the query