I'm creating a textbox where the text will automatic update into mysql after user type and without submit.Problem now is the textbox doesn't not update the database. This is what i edited by refering to all the opinion below.yet still have some problem but is better than nothing display now.thanks.
here is the textbox input
echo "<td class=\"align-center\"><input type=\"text\" name=\"comment\" id=\"comment\" onKeyPress=\"getComment($id,this)\" /></td>";
here is my javascript
function getComment(id, txt_box)
{
var value = txt_box.value;
$.ajax({
'url': 'updatecomment.php',
'data': {"id": id, "comment": value},
'success': function (response) {
console.log(response);
//TODO: use server response
}
});
}
and last is updatecomment.php
<?php require_once("../includes/connection.php") ?>
<?php require_once("../includes/functions.php") ?>
<?php
$id =$_GET['id'];
$comment = $_GET['comment'];
$query = "UPDATE tblinternapplication SET comment = '".mysql_real_escape_string($comment) ."' WHERE id = $id";
$result = mysql_query($query, $connection);
?>
mysql_*functions. use MySQLi or PDO instead."is missing for$query = "...