Try following
while ($row = mysql_fetch_array($result)) {
echo '<input type="radio" name="studentID" value="'.$row['studentID'].'"> '.$row['studentName'].'<br>';
}
Pergunta
This is my code for the selection list, i need to modify the code so instead of a drop-down select list, its a bunch of radio buttons (whithout hard coding).
<?php
mysql_connect('hostname', 'username', 'password');
mysql_select_db('database-name');
$sql = "SELECT studentID FROM student ";
$result = mysql_query($sql);
echo "<select name='studentID'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['studentID'] . "'>" . $row['studentName'] . "</option>";
}
echo "</select>";
?>
Any help would be appreciated.
Solução
Try following
while ($row = mysql_fetch_array($result)) {
echo '<input type="radio" name="studentID" value="'.$row['studentID'].'"> '.$row['studentName'].'<br>';
}