I will simplify the code in order to highlight what I need:
<form id="highlighttable" name=form1 method="POST">
<div class="form-group">
<button name="save_multicheckbox" class="btn-primary">Save Checkbox</button>
</div>
<?php
if(isset($_POST['save_multicheckbox'])){
echo "<p>yes</p>";
$checklist = $_POST['ckb'];
foreach($checklist as $list) {
echo "<p>as</p>";
}
}
?>
<table>
<tr id="col-title">
<th>Title</th>
<th>Type</th>
<th>Post Date</th>
<th>Url</th>
<th>Feature</th>
</tr>
<?php foreach($result as $res){
?><tr>
<td><h6>Lorem</h6></td>
<td><h6>Lorem</h6></td>
<td><h6>Lorem</h6></td>
<td><h6>Lorem</h6></td>
<td id="h-center"><input type="checkbox" name="ckb[]" onclick="chkcontrol(<?php echo $res->chkbox_num; ?>)">
</td>
</tr>
<?php
} ?>
</table>
</form>
I have foreach from my select query, which outputs table rows below:
<?php foreach($result as $res){} ?>
output:
what I am trying to do is to echo or retrieve the rest of the columns on each selected row by marking what I want to get with a checkbox (last column)
<td id="h-center"><input type="checkbox" name="ckb" onclick="chkcontrol(<?php echo $res->chkbox_num; ?>)"></td>
my problem is that my foreach does not output the selected rows with that I tried below:
if(isset($_POST['save_multicheckbox'])){
echo "<p>yes</p>";
$checklist = $_POST['ckb'];
foreach($checklist as $list) {
echo "<p>as</p>";
}
}
first I tried to add an echo inside the button to check if it works and it does, I am just wondering how to show the selected rows. Is there maybe an issue with the variable I am using to get it? my attempt is $checklist = $_POST['ckb'];
where ckb
is the name of the checkbox.