Page 1 of 1
Getting value frm checkbox array
Posted: Tue Oct 04, 2005 2:53 am
by winsonlee
Code: Select all
foreach ( $body1 as $value ) {
echo '<tr>';
echo '<td class="pformleft" width="53%">';
echo $value;
echo '</td>';
echo '<td class="pformright" valign="top" width="33%" colspan="2" align="center">';
echo '<input type="checkbox" name="delete[]" value="index'.$counter.'">';
echo '</td>';
echo '</tr>';
$counter++;
}
after submitting the form, how can i get the value for the checkbox that are submitted ??
Posted: Tue Oct 04, 2005 3:03 am
by ruchit
use $_POST['delete'] to get values posted. To print the values, you can use
Code: Select all
<?php
print_r $_POST['delete'];
?>
Posted: Tue Oct 04, 2005 3:10 am
by winsonlee
how can i print value by value ??
like if checkbox 1 is true then echo checkbox 1 value
if checkbox 2 is true then echo checkbox 2 value
Posted: Tue Oct 04, 2005 3:17 am
by ruchit
it would only show the selected values... so you can use
Code: Select all
foreach( $_POST['delete'] as $val )
echo $val."<br> \n";
Posted: Tue Oct 04, 2005 3:20 am
by pilau
Winsonlee when posting PHP code on the forums please use PHP tags.
About your question: Exactly like you specified.
I'm not certain, but you could use isset(), since cheboxes that are not checked are removed.