Brother Rookie, ask a question, Master help AH!!!!!!
The little brother wants to do a click on the data in the table can be edited online. After editing, press ENTER to directly put the newly modified data into the storage!!
HTML code:
$sql = "SELECT * FROM News", $result =mysql_query ($sql), while ($rs =mysql_fetch_array ($result)) {?>
|
|
}?>
jquery Code:
$ (function () {
var NUMTD = $ ("tr Td:even");
Numtd.click (function () {
var input=$ (" ");
Input.css ("Border-width", "0");
var tdobj=$ (this);
Input.width (Tdobj.width ());
Input.val (tdobj.html ());
Tdobj.html ("");
Input.appendto (Tdobj);
Input.get (0). Select ();
Input.click (function () {
return false;
});
Input.keyup (function (event) {
var keycode = Event.which;
var Inputtext = $ (this). Val ();
if (keycode = = 13) {
$.get ("http://127.0.0.1:8080//100/jquery/insert.php?name=" +inputtext);
}
if (KeyCode ==27)
{
tdobj.html (text);
}
});
});
});
PHP code
$name =$_get["id"];
$name =$_get["name"];
$title =$_get["title"]
$sql = "Update news set name= ' $name ' where id= ' $id '";
mysql_query ($sql);
Run the effect, click to edit. But the carriage return cannot be put into storage. Please master solution!!!! Thank you!!
------Solution--------------------
$name =$_get["id"]; Is this a typo or your intending?
I can ' t find the place where do you input your ID field,
$sql = "Update news set name= ' $name ' where id= ' $id '";
But request here somehow.
------Solution--------------------
$name =$_get["id"];//link does not have an ID
$name =$_get["name"];
$title =$_get["title"]//link does not have title