javascript - Not able to save updated rows in table column with php -
i troubling save records in update set statement within php. im using javascript update record on submit. see below code:
/* update record */ $(document).on('submit', '#emp-updateform', function() { $.post("update.php", $(this).serialize()) .done(function(data){ $("#dis").fadeout(); $("#dis").fadein('slow', function(){ $("#dis").html('<div class="alert alert-info">'+data+'</div>'); $("#emp-updateform")[0].reset(); $("body").fadeout('slow', function() { $("body").fadeout('slow'); window.location.href="home.php"; }); }); }); return false; }); /* update record */
note above method retrieving file update.php update set statement lies. see code:
if(isset($_post)){ $stmt = $update->runquery("update individualproduct set name=:name,model=:model,manufacturer=:manufacturer,productionyear=:productionyear,color=:color,purchaseamount=:purchaseamount id_product=:id"); $stmt->bindparam(":name",$pname); $stmt->bindparam(":model",$pmodel); $stmt->bindparam(":manufacturer",$pmanuf); $stmt->bindparam(":productionyear",$pyear); $stmt->bindparam(":color",$pcolor); $stmt->bindparam(":purchaseamount",$pamount); $stmt->bindparam(":id",$id); $id = $_post['id_product']; $pmanuf = $_post['pmanuf']; $pname = $_post['pname']; $pmodel = $_post['pmodel']; $pyear = $_post['pyear']; $pcolor = $_post['pcolor']; $pamount = $_post['pamount']; $stmt->execute();}
here edit_form.php records column retrieved when editing:
<form method='post' id='emp-updateform' action='#'> <table class='table table-bordered'> <input type='hidden' name='id' value='<?php echo $row['id_product']; ?>' /> <tr> <td>mærke</td> <td><input type='text' name='manufacturer' class='form-control' value='<?php echo $row['manufacturer']; ?>' required></td> </tr> <tr> <td>navn</td> <td><input type='text' name='name' class='form-control' value='<?php echo $row['name']; ?>' required></td> </tr> <tr> <td>model</td> <td><input type='text' name='model' class='form-control' value='<?php echo $row['model']; ?>' required></td> </tr> <tr> <td>Årgang</td> <td><input type='text' name='productionyear' class='form-control' value='<?php echo $row['productionyear']; ?>' required></td> </tr> <tr> <td>pris</td> <td><input type='text' name='purchaseamount' class='form-control' value='<?php echo $row['purchaseamount']; ?>' required></td> </tr> <tr> <td>farve</td> <td><input type='text' name='color' class='form-control' value='<?php echo $row['color']; ?>' required></td> </tr> <tr> <td colspan="2"> <button type="submit" class="btn btn-primary" name="btn-update" id="btn-update"> <span class="glyphicon glyphicon-plus"></span> save updates </button> </td> </tr> </table>
when enter value "acer" in row, example in "manufacturer" row value = "asus" , click on submit (save updates), value changes "asus" , not being updated input.
Comments
Post a Comment