I have multiple checkbox to get all favourites fruits.
HTML
List Favourite<br>
<table border=1>
<th rowspan=3>Name</th>
<tr>
<th colspan=3>Favourite Fruits</th>
<tr>
<th>Banana</th>
<th>Apple</th>
<th>Mangoes</th>
<tr>
<td>John<input type="hidden" id="U0001"/></td>
<td align="center">
<input type="checkbox" name="fruits[]" value="Banana"/>
</td>
<td align="center">
<input type="checkbox" name="fruits[]" value="Apple"/>
</td>
<td align="center">
<input type="checkbox" name="fruits[]" value="Mangoes"/>
</td>
<tr>
<td>Mark<input type="hidden" id="U0002"/></td>
<td align="center">
<input type="checkbox" name="fruits[]" value="Banana"/>
</td>
<td align="center">
<input type="checkbox" name="fruits[]" value="Apple"/>
</td>
<td align="center">
<input type="checkbox" name="fruits[]" value="Mangoes"/>
</td>
<tr>
<td colspan=4>
<input type="button" value="Submit" id="btnSubmit"/>
</td>
</table>
The steps is:
1. There are 2 users, John and Mark
2. Then We tick the favourites fruits for each
3. After that click the submit button
4. Save it to database
Now the question is: How to get all the value of checkbox checked by each users base on his User ID(on input hidden) by btnSubmit click and store it to database?
Example will save on table
Table
uid | favourites_fruits
U0001 | Apple, Mangoes
U0002 | Banana, Apple
JS
$('#btnSubmit').on('click', function()
{
});