以下代码使用 PEAR 提供的 DB 扩展。我想要一个针对每条记录的单选按钮,以便用户只能从列表中选择一条记录并提交。表中可能有数百条记录。
// Proceed with getting some data...
$res =& $db->query('SELECT * FROM someTable limit 10');
while ($res->fetchInto($row)) {
echo "<tr><td>";
echo $row[0] . "\n</td><td>";
echo $row[1] . "\n </td><td>";
echo $row[2] . "\n</td><td>";
echo $row[5] . "\n</td><td>";
echo $row[6] . "\n</td>";
echo "</tr>";
}