I am trying to learn programming and have to populate a set of radio buttons and submit what is selected to show records from a database. I have already done this with a selection list, but can't quite understand what I need to change to convert it to a radio buttons.
Selection list:
<?php
require_once("dbconn.php");
$sql = "SELECT staffName, staffID FROM staff";
$rs = mysqli_query($dbConn, $sql) or die ('Problem with query' . mysqli_error($dbConn));
?>
<form id="task9" action="task7.php" method="get">
<select name="staffID" id="staffID">
<?php
while($row = mysqli_fetch_array($rs)) {
$name=$row["staffName"];
$staffIden=$row["staffID"];
echo "<option value=".$staffIden.">".$name."</option>";
}
?>
<br><br>
<input type="submit" name="submit" method="get">
<input type="reset" name="reset">
</form>
Radio buttons (all I get is all the names and only One radio button):
<?php
require_once("dbconn.php");
$sql = "SELECT staffName, staffID FROM staff";
$rs = mysqli_query($dbConn, $sql) or die ('Problem with query' . mysqli_error($dbConn));
?>
<form id="task9" action="task7.php" method="get">
<input type = "radio" name="staffID" id="staffID">
<?php
while($row = mysqli_fetch_array($rs)) {
$name=$row["staffName"];
$staffIden=$row["staffID"];
echo "<option value=".$staffIden.">".$name."</option>";
}
?>
Hopefully this question is clear enough.