Dynamically created checkboxes with PHP

message from Shaun on 16 Jul 2004
Hi,

I have a form on my site that lists all of the projects in the system.

<tr>
<td>Test Project</td>
<td><input type="checkbox" value="11" ></td>
</tr>
etc...

How can I check which boxes have been ticked using PHP when the form is
submitted so the database can be updated appropriately?

Thanks for your help
 
Michael Fesser replied to Shaun on 17 Jul 2004
.oO(Shaun)

1) Add a name-attribute to the input-element.
2) Dependent on the used submit method (get or post) check the global
arrays $_GET or $_POST for an element named like the input-element:

HTML:
<input type="checkbox" value="11" name="foo">

PHP:
$foo = isset($_GET['foo']);

Now $foo is either TRUE or FALSE, dependent on the checkbox status.

HTH
Micha
 

Archived message: Dynamically created checkboxes with PHP (Macromedia Dreamweaver Web Design)