My simple suggestion:
<?php
if (!empty($_POST))
{
echo "<pre>";
print_r($_POST);
echo "</pre>";
exit();
}
$ids = array(
0 => array(
'id' => 1,
'code' => 'GHY87',
'description' => 'Hello World'
),
1 => array(
'id' => 2,
'code' => 'OTHER',
'description' => 'Bye World'
)
);
function checkboxes($ids)
{
foreach ($ids as $id)
{
?>
<input type="checkbox" name="ids[]" value="<?php echo $id['id']; ?>" /> <?php echo $id['description'];?> (<?php echo $id['code'];?>)<br />
<?php
}
}
?>
<form id="myForm" method="post">
<?php checkboxes($ids); ?>
<input type="submit" value="Edit" />
or
<a href="#" onclick="document.getElementById('myForm').submit(); return false;">Edit</a>
</form>
output:
<form id="myForm" method="post">
<input type="checkbox" name="ids[]" value="1" /> Hello World (GHY87)<br />
<input type="checkbox" name="ids[]" value="2" /> Bye World (OTHER)<br />
<input type="submit" value="Edit" />
or
<a href="#" onclick="document.getElementById('myForm').submit(); return false;">Edit</a>
</form>
...if check first checkbox and click Edit, you get:
Array
(
[ids] => Array
(
[0] => 1
)
)
...if check boths:
Array
(
[ids] => Array
(
[0] => 1
[1] => 2
)
)