> I'd use an array on some way, but the other option is to see if the var is
> set, else set it to N
> if(isset($_POST['my_checkbox_var'])) {
>     $_POST['my_checkbox_var'] = 'N';
> }
> Probably what I'd do is create an array for the possible checkbox values,
> then USE THAT ARRAY to build the form.  Then I can re-use the array on the
> validation script, checking that each element isset()... if they aren't,
> them to 'N'.

Yes that's what I was doing- because the form has other elements other than
checkboxes I have to distinguish between the checkboxes and the others and
hence a separate array for checkboxes.

> To throw in a curve-ball, you can set the default value for your MySQL
> column to 'N', which means that any value you DON'T write will be 'N', and
> those you do will be 'Y'.

Great idea!  Actually after I posted the question I thought of the same
thing :-).  This is probably the most elegant way.  I am curious though why
PHP doesn't just create the variable anyways and just assign it a null value
if the box is not checked.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to