Dynadot โ€” .com Registration $8.99

Form with many options

Spaceship Spaceship
Watch

riscphree

Established Member
Impact
1
I'm running into a logic problem here. What I'm doing is generating a list of items to be approved, and then have a checkbox in the form when submitted will approve the item and move it to another database table.

My form looks something like this:

Code:
Item ID   |  Item Desc  | Item Num  |  checkbox

for my checkbox, I'm using this:
Code:
<input type="checkbox" value="y" name="{$row['item_id'}">

When I submit the form, how can I go through all the submitted results and verify that they were checked? I know how to grab values with php submitted forms, but I've only done simple text input.
 
1
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
If it is a checkbox with
HTML:
value="y"
and name is (this is an example name, it would be your output from $row...
HTML:
name="rowitem"

You could check if they are checked by doing.

PHP:
if(isset($_POST['rowitem']) && $_POST['rowitem'] == "y") { The box is checked } else { the box is not checked }

Remember if you're testing out form submissions and the like,
PHP:
print_r $_REQUEST;
can be really useful.

I hope I understood you right...

Dan
 
0
•••
If you name all of your checkboxes as an array, you'll be able to access them as an array in your PHP code. So for example:

Code:
<input type="checkbox" value="y" name="checkbox[yournamehere]" />

You can then do:

Code:
foreach ($_POST['checkbox'] as $field)
{
    // $field will be the 'yournamehere' part
}
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back