show.php code page
<meta charset= "UTF-8" ><?PHP//Link Database$link=Mysqli_connect(' 127.0.0.1 ', ' root ', ' root ', ' mfour ');//Set character setsMysqli_query($link, ' Set names UTF8 ');//Stitching SQL$sql= "SELECT * FROM USER";//Execution$res=Mysqli_query($link,$sql);//loop into an array while($a=Mysqli_fetch_assoc($res)){ $data[] =$a;}><table border= "1" > <tr> <th>ID</th> <th> name </th> <th> Password </th> <th> mobile </th> <th> address </th> </tr> <?phpforeach($data as $kk=$v) {?> <tr id= "<?php Echo$v[' id ']?> ' > <td fd= ' id ' ><?phpEcho $v[' id ']?></td> <td fd= ' name ' ><?phpEcho $v[' Name ']?></td> <td fd= "pwd" ><?phpEcho $v[' pwd ']?></td> <td fd= ' phone ' ><?phpEcho $v[' Phone ']?></td> <td fd= ' area ' ><?phpEcho $v[' Area ']?></td> </tr> <?php}? ></table><script src= "Jquery.js" ></script>< ;script>//html () parentheses do not write anything is to value, write a thing is replaced//attr represents a property$ (document). Ready (function () { //Double-click to navigate to a TD label$ ("TD"). DblClick (function () { //get the contents of TD tags varTd_val = $ (this).html (); //get the value of a TD property varFd_val = $ (this). attr (' fd ')); //gets the property value of the TR varTr_val = $ (this). Parents (). attr (' id '); //Replace$ (this). HTML ("<input type= ' text ' id= '" +td_val+fd_val+ "' value= '" +td_val+ ">"); //get the contents of a text box$ ("#" +td_val+fd_val). Blur (function () { varNew_val = $ (this).Val (); $ (This). Parents ("TD").html (new_val); //Request$.post ("insert.php",{ID: Tr_val,//the value of the IDFd:fd_val,//the name of the fieldV:new_val//the value of the field},function(Data,status) { }); }) }) });</script>
PHP processing data page: insert.php
<?PHP//Receive Value$id=$_post[' ID '];$FD=$_post[' FD '];$v=$_post[' V '];//Link Database$link=Mysqli_connect(' 127.0.0.1 ', ' root ', ' root ', ' mfour ');//Set character setsMysqli_query($link, ' Set names UTF8 ');//Stitching SQL$sql= "Update user set$FD=$v' WHERE id=$id";//ExecutionMysqli_query($link,$sql);
jquery click-to-Change +php native code display