I am having trouble populating multiple drop-downs .I need to do it with a single query to db and is it possible to do it within a single while loop? Here is the code.Only the first dropdown(Player) is getting populated.The database table(playerDB) has 2 columns-Player and Game. and the respective dropdowns need to be populated
<form name="form1" action="" method="post">
<fieldset>
<legend>Selecting report</legend>
<p>
<?php
$connect = mysqli_connect('localhost','root','','mydatabase');
if(mysqli_connect_errno($connect))
{
echo 'Failed to connect';
}
else{
echo '';
}
if (!$res=mysqli_query($connect, "SELECT * from playerDB")){
echo ("Error description: " .mysqli_error($connect));
}
?>
<label>Select Player</label>
<select>
<?php
while($row=mysqli_fetch_array($res))
{
?>
<option> <?php echo $row["Player"]; ?> </option
<?php
}
?>
</select>
<label>Select Game</label>
<select id = "myGameList">
<?php
while($row=mysqli_fetch_array($res))
{
?>
<option> <?php echo $row["Game"]; ?> </option>
<?php
}
?>
</select>
Any help would be appreciated,Thanks!