I am doing a CRUD operation using only php and bootstrap. I am stuck in updating now because I cannot send $_GET['updateid'] to my modal.
These are my href, delete href works, but update does not work.
<a href="#myModal?updateid=<?php echo $row['sched_id'];?>" data-toggle="modal" class="btn btn-warning" data-target="#myModal">Update</a> <a href="home.php?deleteid=<?php echo $row['sched_id'];?>" class="btn btn-danger">Delete</a>
This php should take updateid from href and pass it to updateStud () function
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(); } }
this is my function update that takes all the data and executes the request
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; }