php - 工作票预订系统无法验证数据
问题描述
例如,座位号2 5 7 8 9 25
已预订,因此应禁用此功能,并且公共汽车上共有 49 个座位。
我正在从数据库中获取数据,但我无法使用已禁用的预订票验证它。
这是代码:
<?php include_once("connect.php");
$query = "SELECT `seat_no` FROM `booked` WHERE `status`='booked'";
$exexquery = mysqli_query($con, $query);
?>
<form action="index.php" method="POST">
<div class="row" style="width: 20%;margin-left: 20%">
<h2>Select seats</h2>
<?php
$x=1;
while(($result_row = mysqli_fetch_assoc($exexquery)) || ($x < 50)) {
if($result_row['seat_no'] == $x ) {
?>
<div class="col-md-3">
<p><input type="checkbox" name="requiring[]" value="<?php echo $i;?>" required class="required_group" disabled><?php echo $x;?></p>
</div>
<?php
}
else {
?>
<div class="col-md-3">
<p><input type="checkbox" name="requiring[]" value="<?php echo $i;?>" required class="required_group"><?php echo $x;?></p>
</div>
<?php
}
$x++;
}
?>
</div>
<input type="submit" name="submit" value="feel passenger details" style="margin-left:25%">
</form>
解决方案
首先要获取49
您需要删除 where 子句的所有记录
$query = "SELECT `status`,`seat_no` FROM `booked`";// now you will get all 49 rows
status
改为检查,同时$x < 50
从此处删除条件
while($result_row = mysqli_fetch_assoc($exexquery)) {
if($result_row['status'] == 'booked') {
// Add html to display booked seats [2, 5, 7, 8, 9, 25]
}else{
// Add html to display available seats
}
推荐阅读
- java - 处理地图列表
> 在 Java 8 中 - react-native - 如何在react-native中的文本组件上显示模态中的选定值
- facebook - 使用已生成的访问令牌登录 Facebook 的 Graph API?
- java - XML 文档 - 检查父节点,然后遍历文档
- amazon-cloudformation - AWS CloudFormation Parameter values specified for a template which does not require them
- python - AttributeError:“Checkbutton”对象没有“取消选择”属性
- solr - 将文档从索引转换为适合包含在 SolrQueryResponse 中的 SolrDocument 的方法
- c# - 需要在通过wpf中的函数打开的网页中输入username的值
- java - 正则表达式允许在 java 中为空或正的非零数字
- css - 显示来自单个控制器的不同样式通知消息以进行插入、更新或错误