php - How do I retrieve the value from table cell and send it to update page using jeditable -
i have mysql table-activity has 3 columns, namely - id, clientname, status; , displaying 2 columns, namely -,clientname , status using datatables.
now want update clientname value in database displayed in datatable dynamically on editing it. this, used jeditable datatable, don't know how retrieve current cell's id , value , pass them through jeditable php page edit them.please me out.
thanks in advance. here have tried far- html code-
<tbody > <?php $sql= "select * `activity` order clientname asc"; $result = mysqli_query($conn,$sql); while($row = mysqli_fetch_assoc($result)) { $id = $row['id']; $name = $row['clientname']; echo "<tr id=".$row['id']."class='edit_tr'>"; echo $id; echo " <td class='edit'>".$row['clientname']."</td> <td>".$row['status']."</td> </tr>"; } ?> </tbody>
jquery code-
<script> $(document).ready(function() { /* init datatables */ var otable = $('#clientsheet').datatable(); /* apply jeditable handlers table */ $('td', otable.fngetnodes()).editable( 'save.php', { tooltip : 'click cell edit value...', indicator : 'saving...', style : 'display:block;', submit : 'ok', cancel : 'cancel', data : " {'keyid':'id','keyname':'name'}", type : 'select', "callback": function( svalue, x) { var apos = otable.fngetposition( ); otable.fnupdate( svalue, apos[0], apos[1]); /* redraw table new data on server */ otable.fncleartable( 0 ); otable.fndraw(); }, "submitdata": function ( value, settings ) { var apos2 = otable.fngetposition( ); var id2 = otable.fngetdata( apos2[0] ); return { "row_id": this.parentnode.getattribute('id'), "id2": id2[0], "column": otable.fngetposition( )[ 2 ] }; }, "height": "14px", } ); } ); </script>
php code-
<?php include('db.php'); $sql = "update `activity` set clientname = '".$_post['keyname']."' `id` = '".$_post['id']."' "; if($nameresult = $conn->query($sql)){ echo "successful"; } else{ echo "failed"; } ?>
please me out.. in advance
Comments
Post a Comment