我想创建一个单选按钮,它将具有一个独特的roomCode作为基于每一行的选择器。因此,如果roomCode = 1,该行中的唯一标识符将为1.这样我就可以提交一个单选按钮,根据所选的roomCode显示时间表。
这是我的PHP代码:
$numeroOption = $_POST['numero'];
$roomtype = $_POST['roomtype'];
$selectOption = $_POST['parkname'];
$query = "SELECT * FROM `ROOMS` WHERE `Capacity` < '$numeroOption' AND `Park` LIKE '$selectOption%' AND `dataProjector` LIKE '$proj_check%' AND `Whiteboard` LIKE '$white_check%' AND `OHP` LIKE '$ohp_check%' AND `WheelchairAccess` LIKE '$wheel_check%' AND `lectureCapture` LIKE '$cap_check%' AND `Style` LIKE '$roomtype%'";
$result = mysql_query($query);
if ($result == FALSE)
die ("could not execute statement $query<br />");
echo "<table>";
while($row = mysql_fetch_array($result))
{
echo "<tr><td>" . $row['roomCode'] . "</td><td>" . $row['Park'] . "</td><td>" . $row['Capacity'] . "</td><td>" . $row['Style'] . "</td><td>" . $row['dataProjector'] . "</td><td>" . $row['Whiteboard'] . "</td><td>" . $row['OHP'] . "</td><td>" . $row['wheelchairAccess'] . "</td><td>" . $row['lectureCapture'] . "</td></tr>";
}
echo "</table>";
mysql_close();
}
答案 0 :(得分:0)
对于初学者,你应该使用mysqli或PDO。如果你将使用多个数据库(mysql和sql等),PDO是最好的,但如果没有,我更喜欢mysqli,因为我觉得它更有效。
解决问题...
<form>
while($row = mysql_fetch_array($result))
{
echo "<tr><td><input type="radio" name="radioSelect" value= "" checked="" /></td><td>" . $row['roomCode'] . "</td><td>" . $row['Park'] . "</td><td>" . $row['Capacity'] . "</td><td>" . $row['Style'] . "</td><td>" . $row['dataProjector'] . "</td><td>" . $row['Whiteboard'] . "</td><td>" . $row['OHP'] . "</td><td>" . $row['wheelchairAccess'] . "</td><td>" . $row['lectureCapture'] . "</td></tr>";
}
}
<input type="submit"/>
</form>