# PHP and checkboxes HELP!

**URL:** <https://forum.kirupa.com/t/php-and-checkboxes-help/36355>\
**Category:** programming\
**Created:** [November 25, 2003, 7:53pm UTC](https://forum.kirupa.com/t/php-and-checkboxes-help/36355 "2003-11-25T19:53:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheddar](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/cheddar/32/267_2.png) [@cheddar](https://forum.kirupa.com/u/cheddar)\
**Post date:** [November 25, 2003, 7:53pm UTC](https://forum.kirupa.com/t/php-and-checkboxes-help/36355/1 "2003-11-25T19:53:04Z")

</div>

Can anyone help me out with a problem I have with a form. I am using PHP to get some information from the form but the form uses checkboxes which has got me confused.

I have the user select a number of ‘items’ with a simple checkbox. If the box is checked then the value ‘Y’ gets passed from it, thats fine.

The problem is that I want to store a ‘N’ in the database if the user doesnt select a option. Is there anyway to get a ‘N’ passed if the checkbox is not checked?

My other idea was once I have all the details in the $POST array, and have transfered them to indivudal variables (atrib1…atrib30), I will then check each of these to see if it holds the value ‘Y’ if not then I will change it to ‘N’.

Is there anyway of doing this without having 30 if else statements?

I thought I had it done by doing the following:

```php

$i = 0;
do {
   if atrib[$i] != 'Y' {
                 atrib[$i] = 'N';
                  $i++; 
   } else {
                 $i++;
   }

} while ($i>0);

```

I dont think this is correct though, i’m not sure if the syntax is wrong or if my logic is wrong. Will I be able to access each attrib with attrib[$i]? I thought that on each run through the loop ‘i’ would increment so it would be like atrib1,atrib2,atrib3…etc

Can anyone help me out here?
