gpt4 book ai didi

php - 如何从 HTML/PHP 页面删除 mySQL 中选定的记录?

转载 作者:行者123 更新时间:2023-11-29 23:17:17 25 4
gpt4 key购买 nike

我的想法是单击“删除”链接,它会将 id 传递到另一个 PHP 页面(deleteSession.php),然后在 deleteSession.php 中执行查询。但我似乎无法从manageSession.php获取id

ma​​nageSession.php中,

<table align='center' border='1' cellpadding='5' cellspacing='0'>    
<tr>
<th>Session Id</th>
<th>Type</th>
<th>Date & Time</th>
<th>Venue</th>
<th>Pax</th>
<th>Delete</th>
<th>Edit</th>
</tr>

<?php
$sql = "SELECT booking_id, booking_types, dates_sessions, venue_available, room_count FROM bookings_available ORDER BY dates_sessions asc";
$result = mysqli_query($link, $sql) or die(mysqli_error($link));
//mysqli_close($link);

while ($row = mysqli_fetch_array($result)) {
?>
<tr>
<td><?php echo $row['booking_id']; ?></td>
<td><?php echo $row['booking_types']; ?></td>
<td><?php echo $row['dates_sessions']; ?></td>
<td><?php echo $row['venue_available']; ?></td>
<td><?php echo $row['room_count']; ?></td>
<td><a href="deleteSession.php?id=<?php echo $row['booking_id']; ?>"><input type="button" value="Delete"/></a></td>
<td><a href="editSession.php?id=<?php echo $row['booking_id']; ?>"><input type="button" value="Edit"/></a></td>
</tr>
<?php } ?>
</table>

deleteSession.php中,

<?php
include "dbFunctions.php";
include "manageSession.php";

//$sql = "SELECT booking_id, booking_types, dates_sessions, venue_available, room_count FROM bookings_available";
//$result = mysqli_query($link, $sql) or die(mysqli_error($link));

$bookingId = filter_input(INPUT_GET, 'booking_id');

$deleteQuery = "DELETE FROM bookings_available WHERE booking_id = '$bookingId'";

?>

最佳答案

我认为deleteSession.php文件中的代码应该如下。

$bookingId = filter_input(INPUT_GET, 'id');

或者

$bookingId = $_GET['id'];

因为您按如下方式传递 get 参数。

deleteSession.php?id=

并按如下方式保持锚定。

<a href="deleteSession.php?id=<?php echo $row['booking_id']; ?>">Delete</a>

关于php - 如何从 HTML/PHP 页面删除 mySQL 中选定的记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27664389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com