[Solved] How to get the value from and save to Database in php


You have at least two options here:

hidden fields everywhere if data (best approach):

<td>
    <input type="checkbox" name="checkBox[]"  id="ic" value="{{ user.id }}" />
    <input type="hidden" value="{{user.lastname}}" name="v1[{{ user.id }}]"></td>
<td  data-title="id">{{user.id}}</td>
<td data-title="firstName">{{user.firstname}}</td>
<td data-title="lastName" contenteditable="true">{{user.lastname}}</td>

and on serverside you do:

.... your code ....
foreach ($user  as $id) {
    $lastname = $v1[$id];
    ... save your lastname value ...
}

Anothe option is to set checkbox value with data separated by some value (ugly solution)

<td><input type="checkbox" name="checkBox[]"  id="ic" value="{{ user.id }}#{{user.lastname}}" /></td>
            <td  data-title="id">{{user.id}}</td>
            <td data-title="firstName">{{user.firstname}}</td>
            <td data-title="lastName" contenteditable="true" name="v1">{{user.lastname}}</td>

EDIT

I see now that you are using contenteditable. You should add the value to your hidden field:

$("form").submit(function() {
    $('input[name*="v1"]').val($(this).closest('td[name="v1"]').html());
});

<td>
    <input type="checkbox" name="checkBox[]"  id="ic" value="{{ user.id }}" />
    <input type="hidden" value="{{user.lastname}}" name="v1[{{ user.id }}]"></td>
<td  data-title="id">{{user.id}}</td>
<td data-title="firstName">{{user.firstname}}</td>
<td data-title="lastName" contenteditable="true" name="v1">{{user.lastname}}</td>

2

solved How to get the value from

and save to Database in php