jquery - How Can Update MySQL field Using Ajax And PHP -
i want update data in mysql database using ajax , php.
html
<td><input type="text" class="event" name="title<?php echo $row['id']?>" id="title_id_<?php echo $row['id']?>" value="<?php echo $row['title']?>" disabled/></td> <td><input type="datetime" class="event" name="start<?php echo $row['id']?>" id="start_id_<?php echo $row['id']?>" value="<?php echo $row['start']?>" disabled/></td> <td><input type="datetime" class="event" name="end<?php echo $row['id']?>" id="end_id_<?php echo $row['id']?>" value="<?php echo $row['end']?>" disabled/></td> <td><div class="edit_wrapper"><a href="#" class="edit_button" id="edit-<?php echo $row['id'] ;?>"><img src="http://icons.iconarchive.com/icons/custom-icon-design/flatastic-1/24/edit-icon.png"/></a></td> <td><div class="up_wrapper"><a href="" class="up_button" id="up-<?php echo $row['id'] ;?>"><img src="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/24/actions-svn-update-icon.png"/></a></td> <td><div class="del_wrapper"><a href="" class="del_button" id="del-<?php echo $row['id'] ;?>"><img src="http://icons.iconarchive.com/icons/hopstarter/button/24/button-delete-icon.png"/></a></td>
jquery ajax code
$('.up_button').click(function(){ var btnid=this.id; btnid=btnid.replace(/\d/g, ''); btnid=parseint(btnid, 10); var e_title=$('#title_id_'+btnid).val(); var e_start=$('#start_id_'+btnid).val(); var e_end=$('#end_id_'+btnid).val(); $.ajax({ url: 'event_update.php', data:{'title':e_title , 'id':btnid , 'start':e_start, 'end': e_end}, type: "post", success: function() { alert("güncelleme başarılı."); } }); });
here php code(event_update.php)
<?php include_once("config.php"); $id = $_post['bid']; $title = $_post['title']; $start = $_post['start']; $end = $_post['end']; mysql_query("update evenement set title=$title,start=$start,end=$end id=$id")) mysql_close($connecdb); ?>
but couldnt update data.can help?
replace query line this, non numeric entity must enclosed.
mysql_query("update evenement set title='$title',start='$start',end='$end' id='$id'"))
Comments
Post a Comment