我需要为可以看到他预订的所有房间的一个用户取消预订房间。 问题是它显示用户的预订房间,但删除按钮无法正常工作。当我按下按钮时从MySQL表中删除行删除
谢谢。
下面是节目的预约资料我的PHP代码,并在manage.php
<?php
session_start();
$connection = mysqli_connect('localhost', 'root', '', 'webapp');
global $connection;
$user_id="";
if(!isset($_SESSION['login_ID'])) {
header('Location: login.php');
die();
} else {
$user_id= $_SESSION['login_ID'];
}
$secondQueryStmt = "SELECT * FROM `booking` where UserID='".$user_id."'";
$query = mysqli_query($connection, $secondQueryStmt);
if(isset($_POST['BookingID'])) {
$boking_id = $_POST['BookingID'];
if(isset($_POST['delete_id'])){
$query = mysqli_query($connection, "DELETE FROM booking where BookingID= '".$boking_id."'");
}
}
?> 这里是在同一个页面也是我的HTML表单中删除的部分。
<article id="content" style="height:810px; background-color:white">
<div class="box1">
<!--content herer-->
<table class="wrapper" style="text-align:center">
<tr>
<th class="track animated fadeInUp">Room</th>
<th class="title animated fadeInUp">Quantity</th>
<th class="speaker animated fadeInUp">CheckIn Date</th>
<th class="day animated fadeInUp">CheckOut Date </th>
<th class="time animated fadeInUp"></th>
</tr>
<?php while($fetcher = mysqli_fetch_array($query)): ?>
<tr>
<td><?=$fetcher['Type']?></td>
<td><?=$fetcher['Quantity']?></td>
<td><?=$fetcher['CheckInDate']?></td>
<td><?=$fetcher['CheckOutDate']?></td>
<td><td><form action="manage.php" method= "post" />
<input type="hidden" name="b_id" value="<?=$fetcher['BookingID'] ?>"/>
<input type="button" class="btnSm hvr-fade lightRed" name="delete_id" value="Cancel Booking"/>
</form></td></tr>
<?php endwhile; ?>
</table>
</div>
</article>
的DELETE后删除* - >从表 – sagi
我不删除t看到任何开头'
执行SQL语句后应检查错误。还要了解准备好的陈述。 – Jens