I am retrieving data from MySQL table and displaying in a HTML Table by <?php foreach ?> loop
like below.
Now I want to edit/delete the data of a particular row of the above HTML table by pressing the edit or delete button of the table. My MySQL
table primary key is branch_code
.
I know how to update/delete data in MySQL table in Codeigniter but I do not know how to retrieve the data from the table row. I could not try because I do not know how to start it.
I found similar questions like
- Get values from html table using codeigniter
- PHP-CodeIgniter: How to get the corresponding html table row values to be deleted by Javascript
In No#1
it was written Collect all this data in an array and "send" it to your PHP via an Ajax POST request.
----- ok great, but how could I do that ?
Can you please help me ?
May be my question is duplicate, but I didn't get any answer from those originals or I would say, I am unable to proceed the process.
Thank you in advance.
Update:
from the No#2
I got the below...
$(document).on('click', '#deleteRow', function() {
var obj = $(this).parent().parent();
var companyId = obj.attr('branch_code');
obj.remove();
});
I understood that I should add unique attribute to <tr>
.
Now how can I pass the value in a variable to a model
so that I can update my MySQL
table ($this->db->where('branch_code', $branch_code);
) ?