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:
$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?