我正在尝试用bootstrap模型更新mysql表数据。但它不起作用。下面的代码在这里。
下面是update.php页面代码
<!-- Data Pass Request Code -->
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update'])) {
$edit_item_id = $_POST['edit_item_id'];
$updateSlider = $sli->sliderUpdate($edit_item_id, $_POST);
}
?>
<!-- Start View And Edit Slider Information Show Pop Up -->
<?php
$sliderdata=$sli->getSliderData();
if ($sliderdata) {
while ($result=$sliderdata->fetch(PDO::FETCH_ASSOC)) {
?>
<div class="modal fade" id="<?php echo $result["id"]; ?>" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body no-padding">
<form action="" method="post" enctype="multipart/form-data" id="contact-form" class="smart-form">
<header>View | Update Slider Information</header>
<fieldset>
<section>
<label class="label">Title | Enter New Title</label>
<label class="input">
<input type="hidden" id="" name="edit_item_id" value="<?php echo $result['id']; ?>">
<input type="text" name="title" value="<?php echo $result['title']; ?>" id="subject">
</label>
</section>
</fieldset>
<footer>
<input type="submit" class="btn btn-primary" value="Update" name="update">
</footer>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<?php } } ?>
<!-- End Slider Information Show Pop Up -->
这是我的类函数代码//start update query
public function sliderUpdate($edit_item_id, $data){
$title = $data['title'];
$edit_item_id = $data['edit_item_id'];
$stmt = $this->pdo->prepare("UPDATE slider SET title=':title' WHERE id=':edit_item_id'");
$stmt->bindParam(":title", $title);
$stmt->bindParam(":id", $edit_item_id);
$stmt->execute();
return $stmt;
}
暂无答案!
目前还没有任何答案,快来回答吧!