your database design is not normalized. this results in repeating the same data values over and over. you should have a column for, and store the Ass_ID value in the mykra table, instead of repeating the 'Point_Description' and 'Point_Marks' values in every row in that table. doing this will also simplify and help secure the form code, since you will no longer be passing the description[] and rating[] fields through the form, and it will simplify the ajax related code.
some points about the code -
you need to stop copying variables to other variables for nothing. this is just a waste of your time typing. just use the original variables that data is in.
you need to go through the code and eliminate all the unused code and unused variables.
an empty action='' attribute is not valid html5. to cause a form to submit to the same page it is on, leave out the entire action attribute.
you cannot set the value attribute of a type='file' field, so you might as well remove that from the ajax code (you aren't setting a 'file' value in the json data, so that code wasn't doing anything anyways.) you would want to build/output the href link using directory/document data.
if there is a validation/user error in the post method form processing code, the form fields need to be 'sticky' and repopulate their values with any existing form data, so that the user doesn't need to keep reentering/editing values over and over.
you havn't posted it yet, but the insert/update query (there's a single query to do this) could result in duplicate data. you need to handle this in the code and setup an error message for the user letting them know what was wrong with the data that they submitted, so that they can modify the offending value and resubmit the data again.
you need to validate the resulting web pages at validator.w3.org
as to getting this to work, the Ass_ID value is the 'key' to finding the correct <tr> row of form inputs to operate on. it is also the 'key' to inserting/updating the correct rows of data in the database table when the form is submitted.
in the html table/form code, you need a hidden array field with the Ass_ID values in it. this will let you associate the submitted Ass_ID values with the corresponding data from the other form array fields. you also need a way of referencing the <tr> for each row. to do this add an id='...' attribute, such as -
<tr id='<?='Aid_'.$row['Ass_ID']?>'>
in the Mykra_view.php code, you need to build the json data with the Ass_ID value, such as -
$return_arr[] = array(
'Aid' => $row['Ass_ID'], // add the Ass_ID to the json data
"target" => $row['Marks_Target'],
"actual" => $row['Marks_Actual'],
"date" => $row['DOS'],
"remarks" => $row['Marks_Description']
);
then in the ajax success code, you would get the Aid value and use it to select/find the correct form field value to set with the data -
<script>
function viewData() {
var month = document.getElementById("Month").value;
var employeeid = document.getElementById("employeeno").value;
$.ajax({
type: 'get',
dataType: 'JSON',
url: 'Mykra_view.php',
data: 'Month=' + month + '&employeeno=' + employeeid,
success: function (response) {
var len = response.length;
for (var i = 0; i < len; i++) {
var Aid = response[i].Aid;
var target = response[i].target;
var actual = response[i].actual;
var date = response[i].date;
var remarks = response[i].remarks;
$('#Aid_'+Aid).find('.target').val(target);
$('#Aid_'+Aid).find('.actual').val(actual);
$('#Aid_'+Aid).find('.date').val(date);
$('#Aid_'+Aid).find('.remarks').val(remarks);
}
}
});
}
</script>
to make the above work, like in your previous thread, you would change the id='...' attributes to class='...' attributes (you would actually add the class names to the existing class='...' attributes.)