如何仅从制表符中检索更新的行数据作为 JSON 对象?
How to retrieve only the updated rows data from the tabulator as a JSON object?
我正在使用 Tabulator,它有一个输入字段,用户可以通过它输入一个数值,我需要将数据按原样上传到 MySQL Database
。但是,我想要一种方法来只获取更新的行,即只获取用户输入值的行,这样我就可以只更新 MySQL Database
中的那些行。
我希望只获取更新的行数据作为 JSON 对象,这样我就可以通过 AJAX Request
.
将它传递给我的 PHP 代码
好的,我来回答你的问题。当你更新一行时,你肯定使用了一个唯一的 id 来更新该行。
更新后,您应该使用相同的唯一 ID,并从已更新的同一行中从数据库中获取数据。
最后将其与 json 编码一起回显,这将是您 ajax 请求的响应,请参阅我的代码,它肯定会工作:-
// update the row where unique id is quote_id
$sqlbt = "UPDATE `quote_data_master_kotak` SET `reg_date` = '$reg_date',
`make_year` = '$makeyear' WHERE `quote_id` = '$quoteid'";
$result = $conn->query($sqlbt); //row updated
//now its time to get the updated row data using quote_id as unique id
$sql = "SELECT * FROM `quote_data_master_kotak` WHERE `quote_id` = '$quote_id'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$updated_row_data = $result->fetch_assoc();
$data['row_data'] = $updated_row_data ;
}
//now you can echo it in Json formate
echo json_encode($data);
// output json like this:-
{
"row_data":{
"quote_id":"5",
"reg_date":"20/11/2018",
"make_year":"2018"
}
}
我正在使用 Tabulator,它有一个输入字段,用户可以通过它输入一个数值,我需要将数据按原样上传到 MySQL Database
。但是,我想要一种方法来只获取更新的行,即只获取用户输入值的行,这样我就可以只更新 MySQL Database
中的那些行。
我希望只获取更新的行数据作为 JSON 对象,这样我就可以通过 AJAX Request
.
好的,我来回答你的问题。当你更新一行时,你肯定使用了一个唯一的 id 来更新该行。 更新后,您应该使用相同的唯一 ID,并从已更新的同一行中从数据库中获取数据。 最后将其与 json 编码一起回显,这将是您 ajax 请求的响应,请参阅我的代码,它肯定会工作:-
// update the row where unique id is quote_id
$sqlbt = "UPDATE `quote_data_master_kotak` SET `reg_date` = '$reg_date',
`make_year` = '$makeyear' WHERE `quote_id` = '$quoteid'";
$result = $conn->query($sqlbt); //row updated
//now its time to get the updated row data using quote_id as unique id
$sql = "SELECT * FROM `quote_data_master_kotak` WHERE `quote_id` = '$quote_id'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$updated_row_data = $result->fetch_assoc();
$data['row_data'] = $updated_row_data ;
}
//now you can echo it in Json formate
echo json_encode($data);
// output json like this:-
{
"row_data":{
"quote_id":"5",
"reg_date":"20/11/2018",
"make_year":"2018"
}
}