Skip to content Skip to sidebar Skip to footer

Displaying Php Echo $row Data Into Bootstrap Modal Form

I currently have the following datatable to display my list of contacts from the database. Each row, I have also insert a 'Edit' & 'Delete' button and have the data-id='

Solution 1:

1 - you are sending a encoded json from your php file and use it directly from you javascript code which is invalid so to speak,

2 - you are sending the data object to php using ajax wrongly, it should be as follows instead data: {id: uid},

3 - you are declare the wrong data-id , it should be as follows: var uid = $(this).attr('data-id');

you need to decode your json response as follows:

var uid = $(this).attr('data-id');
$.ajax({
    url: 'getcontact.php',
    method: 'POST',
    data: {id: uid},
    success: function(response){
    var result = JSON && JSON.parse(response) || $.parseJSON(response);
    ...
    // rest of your code
    ...

Update

and you have an issue in this part:

while($row = mysqli_fetch_array($result)){
    $rows[] = $row['*'];
}

to add the whole array you need to do as follows:

while($row = mysqli_fetch_array($result)){
    $rows[] = $row;
}

Post a Comment for "Displaying Php Echo $row Data Into Bootstrap Modal Form"