0

I am trying to update Mysql Table data with the bootstrap model. But it is not working. the code below here.

Here is update.php page code

<!-- 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 -->

And This Is My Class Function Code //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;
}
  • Placeholders should not be quoted -> `SET title= :title WHERE id= :edit_item_id` NOT `SET title=':title' WHERE id=':edit_item_id'` (see https://stackoverflow.com/a/11321508/689579/) – Sean Jun 06 '18 at 04:53
  • Hi Sean. Thanks for your comment. I did it. But Data not updating. –  Jun 06 '18 at 05:08

0 Answers0