I have a country table with 2 columns (id and country name) and I'm using the technique mentioned in the answer to the Fetching data from MySQL database to html drop-down list post to fill a HTML drop-down list with the country names however, the instead of populating the list box the countries are being listed outside and below it. Any clues appreciated.
<tr height="29px"><td width = "200px"><b>Your Country</b></td>
<td>
<select name="country" id="country">
<option value="10">First copuntry<option>
<option value="10">Second copuntry<option>
<option value="10">Second copuntry<option>
<?php
$sql = "SELECT * FROM countries";
$result = mysqli_query($con, $sql);
?>
<select name="select1">
<?php
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "</option>";
}
?>
</select>
<?php
mysqli_free_result($result);
mysqli_close($con);
?>
</td>
</tr>
This is the resulting output