这是我的选择列表的代码,我需要修改代码,而不是下拉选择列表,它是一堆单选按钮(没有硬编码)。
<?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>";
?>
任何帮助都将不胜感激。
答案 0 :(得分:2)
尝试以下
while ($row = mysql_fetch_array($result)) {
echo '<input type="radio" name="studentID" value="'.$row['studentID'].'"> '.$row['studentName'].'<br>';
}