I am working with Tabulator which has an Input Field in it through which the user can enter a numeric value, and I need to upload the data from it as it is to MySQL Database
. However, I want a way to get only the updated rows i.e. only the rows in which the user has entered value so that I can just update those rows in MySQL Database
.
I wish to get only the updated row data as a JSON Object so that I can just pass it to my PHP code through the AJAX Request
.
Asked
Active
Viewed 342 times
0

Mayank Patel
- 3,868
- 10
- 36
- 59

Sourabh
- 17
- 7
-
post what yo have done so far – Anantha Raju C Jun 01 '19 at 05:21
1 Answers
-1
Ok let me answer your question. While you are updating a row then definitely you have used a unique id to update the row. After update you should use that same unique id and fetch the data from database from that same row which you have updated. And at last put it in echo with json encode that will be the response of you ajax request see my code it will work for sure:-
// 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"
}
}

CodeBreaker
- 395
- 2
- 9
-
How were you able to get this code without any thing mentioned in the question ? – dota2pro Jun 03 '19 at 17:48
-
-
I want you to answer, but do not put insecure code and wrong code in your answers. I will take my down vote away if you improve the quality of your answer. First of all use prepared statements and proper code indentation. – Dharman Jun 22 '19 at 00:24
-
Why you down voted my accepted answer@Dharman.See you are not the only who is the master of SQL Injection.There is many way to avoid SQL Injections.A lots of people used this code and you downvoted it. – CodeBreaker Jun 22 '19 at 00:27
-
I am afraid for the people who used this code. Could you list all the ways to prevent SQL injection? I know only one: separate the data from query. [How can I prevent SQL injection in PHP?](https://stackoverflow.com/a/60496/1839439) – Dharman Jun 22 '19 at 00:30
-
I can list.But i will not because it seems like you behaving like a God in SQL Injections :).How many comments of warnings and down votes you put in a days? – CodeBreaker Jun 22 '19 at 00:37