Form with many options

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
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
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back