Show Checkbox Checked In The Table
I have a problem showing the selected check value in the table. Now I cannot follow my selected value to show the check values in each row in the table. For example below coding,
Solution 1:
In your code there is $tick
value every time the same, for all checkboxes.
If you have tick values in array, than it's quite easy. In each row check $myArray[X]
value.
<td><input type="checkbox" id="checkbox_val" name="checkbox_val" value="0" <?php echo $myArray[0] === 'true' ? 'checked' : '';?>> </td>
You can do it in loop, than code would be st. like (expected you have contact&country in any array too)
<table>
<tr><th>....</th></tr>
<?php
foreach ($myArray as $k => $va) {
?>
<tr>
<td>...</td>
<td><input type="checkbox" id="checkbox_val" name="checkbox_val" value="0" <?php echo $va === 'true' ? 'checked' : '';?>> </td>
<td><?php echo $contact[$k] ?></td>
<td><?php echo $country[$k] ?></td>
</tr>
<?php
}
?>
</table>
Post a Comment for "Show Checkbox Checked In The Table"