使用下拉列表我从列表中选择数据:
<option value="R.K.Hospital">R.K.Hospital </option>
<option value="Sevabhai Hospital">Sevabhai Hospital</option>
现在使用这部分代码我正在检查座位是否可用:
$queryreg = mysql_query("SELECT available FROM hospital WHERE h_name='$hospital' ");
$queryreg = mysql_fetch_assoc($queryreg);
$a= $queryreg;
echo '<span style="color:ff0000;text-align:center;">Available seats are , '.$a['available'].' </span>';
if($a['available']>0)
{
echo (" <form action='book_bed.php' method='post'><input name='submit' type='submit' value='Book Now' /> </form>");
}
现在我想预订座位,如果有座位......
<?php
include_once('connection.php');
include_once('available.php');
$hospital=$_POST['hospital'];
$username=$_SESSION['username'];
$date=date("Y-m-d");
if(@$_POST['submit'])
{
$queryreg = mysql_query("INSERT INTO `bed_book` VALUES ('$username','$hospital','')",$connect);
echo'<span style="color:#AFA;text-align:center;">Order Has Been Booked !!</span>';
}
?>
除了$ hospital变量之外,所有内容都插入到数据库中......我猜有一些实现问题......连接和数据库工作得很好,所以没有问题。如果有人可以提供帮助,我会感激...
答案 0 :(得分:0)
在您的表格中没有任何医院输入
echo (" <form action='book_bed.php' method='post'>
<input name='hospital' type='hidden' value='".$hospital."' />
<input name='submit' type='submit' value='Book Now' />
</form>");
并在提交后,您将获得它的价值
$queryreg = mysql_query("INSERT INTO `bed_book` VALUES ('$username','".$hospital."','')",$connect);