我正在使用php和bootstrap进行CRUD操作.我目前卡在更新,因为我似乎无法将$_GET [‘updateid’]发送到我的模态.
这是我的href,删除href正在工作,但更新不是.
class="btn btn-warning" data-target="#myModal">Update
这个php应该从href获取updateid并将其传递给updateStud()函数
if(isset($_GET['updateid'])){
$mupdate_id = $_GET['updateid'];
if(isset($_POST['modal-submit'])){
$msubj = $_POST['modalsubject'];
$msect = $_POST['modalsection'];
$mday = implode("", $_POST['modalday']);
$mstrTime = $_POST['modalstarttime'];
$mendTime = $_POST['modalendtime'];
$auth_user->updateSchedule($msubj,$msect,$mday,$mstrTime,$mendTime,$mupdate_id);
$schedRow = $auth_user->readSchedule();
}
}
这是我的函数更新,它获取所有数据并执行查询
public function updateSchedule($msubj,$msect,$mday,$mstrTime,$mendTime,$mupdate_id){
$stmt = $this->conn->prepare("UPDATE `schedule`
SET `subject_db` = :msubj,
`section_db` = :msect,
`sched_day` = :mday,
`start_time` = :mstrTime,
`end_time` = :mendTime
WHERE `sched_id` = :mupdate_id ");
$stmt->bindparam(":msubj", $msubj);
$stmt->bindparam(":msect", $msect);
$stmt->bindparam(":mday", $mday);
$stmt->bindparam(":mstrTime", $mstrTime);
$stmt->bindparam(":mendTime", $mendTime);
$stmt->bindparam(":mupdate_id", $mupdate_id);
$stmt->execute();
return $stmt;
}