是否可以添加一个包含 ID 的 href 以在运行确认函数中?我的目标是在我单击“接受”后显示一个弹出窗口,并且接受按钮从 isset 执行查询。
这是我接受的代码。
$displaybody .= "<tr>
<td>" . $rows['lname'] . ", " . $rows['fname'] . "</td>
<td>" . $rows['subject'] . "</td>
<td>" . $rows['days'] . " " . $rows['rstime'] . " - " . $rows['retime'] . "
</td>
<td>" . $rows['note'] . "</td>
<td>
<a class='runConfirm' data-id='" . $rows['rid'] . "'>Accept</a>
<a href='home.php?decline=" . $rows['rid'] . "'>Decline</a>
</td>
</tr>"
这是我的弹出窗口功能。(已更新)
<script type='text/javascript'>
$(function(){
$('.runConfirm').click(function(event){
// get the id you want to act on
var theId = $(this).data('rid');
// ask user for confirmation
alertify.confirm('Are you sure to accept this request?',
// accepted
function(){
// go to the processing page
window.location('/accept.php?rid=' + theId);
},
// declined
function(){
alertify.error('You clicked CANCEL');
}).set('closable', false);
});
});
</script>
接受.php包含接受预订的流程。
<?php
include("server.php");
session_start();
if(isset($_GET['accept']))
{
$rid=$_GET['accept'];
$query=$mysqli->query("SELECT qid FROM requests WHERE rid='".$rid."'");
if($query->num_rows>0)
{
while($rows=$query->fetch_assoc())
{
$qid=$rows['qid'];
}
}
$query1=$mysqli->query("UPDATE qualified SET status='accepted' WHERE
qid='".$qid."' ");
$query=$mysqli->query("UPDATE requests SET action='accepted' WHERE
rid='".$rid."'");
header("Location:home.php");
}
?>
MMTTMM
墨色风雨
随时随地看视频慕课网APP