我创建了一个带有单选按钮的PHP表单,因此提交它将根据我选择的那个生成一个roomCode。一旦按下提交按钮,我很难显示其他SQL语句。
PHP:
<?php
if( isset( $_POST['submit'] ) )
{
if(isset($_POST['proj_check']))
$proj_check = $_POST['proj_check'];
else
$proj_check = "N";
$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 "<form action='' method='post'>";
echo "<table>";
while($row = mysql_fetch_array($result)){
echo "<tr><td>" . $row['roomCode'] . "</td></tr>";
echo "<td><input type='radio' name='radioSelect' value= '". $row['roomCode']."'></td>";
}
echo "<input type='submit' name='ttroom' id='ttroom' name='ttroom'>";
echo "</tr>";
echo "</table>";
echo "</form>";
}
if( isset( $_POST['ttroom'] ) )
{
$roomcode = $_POST['ttroom'];
$try = "SELECT * FROM 'ROOMBOOKING' WHERE 'roomCode' = '$roomcode';";
$ttres = mysql_query($try);
if ($ttres == FALSE) die ("could not execute statement $try<br />");
echo "<table>";
while($ttrow = mysql_fetch_array($ttres)){
echo "<tr><td>" . $ttrow['roomCode'] . "</td>";
}
echo "</tr>";
echo "</table>";
}
mysql_close();
?>
答案 0 :(得分:0)
以下是我假设您正在尝试做的事情的示例:
网站:强>
http://www.w3schools.com/php/php_form_complete.asp
以上链接的作用基本上是创建一个表单,设置一些表单验证并要求用户填写表单。一旦用户完成表单并提交表单,它就会回显输入的结果。现在我假设这就是你要找的东西。如果您担心与数据库通信,您基本上可以将所有表单字段名称放入单个变量中,然后同时运行插入查询。因此,您可以根据插入查询进行回显。现在我注意到在你的代码中,你使用了一个表...表单,表格......概念是一样的。试一试,让我知道你得到了什么!
希望这有帮助,
苏海尔