Page 1 of 1

Use checkboxes to display selected records

Posted: Fri Apr 27, 2007 1:44 pm
by manton
Hello,
I have a table on a form which contains records that can be multiple selected by checkboxes. A submit button sucessfully sends the record IDs of the checked records to the next page.

I want to display the records that were selected via the checkboxes, but the problem is that I get only the first of them.

Any help would be really appreciated, thanks

Posted: Fri Apr 27, 2007 2:06 pm
by John Cartwright
you need to change your checkbox to be an array

Code: Select all

<input type="checkbox" name="fieldname[]" value="foo">
<input type="checkbox" name="fieldname[]" value="bar">
<input type="checkbox" name="fieldname[]" value="foobar">

<?php
//on submit
echo '<pre>';
print_r($_POST['fieldname'])
?>
Which will provide you an array of your values for fieldname[]