I have caught some information from a form with checkboxes and placed this into variables. The problem is that if the user doesnt click on a checkbox then the value passed will be nothing/null/zip/nadda, I want that value to be 'N' instead.
I have 30 of these checkboxes, I want all the variables that hold the information on these checkboxes to have a 'Y' or 'N'. The 'Y' is no problem as that value is passed when I access the $POST array. The 'N' value is what I am struggling with though.
I have come up with this code below to try and fix my problem. Instead of having 30 'If' statements I want to use a loop of some kind, but it's not working. I am a complete novice with PHP so i'm not sure if my logic is wrong or if it's something else.
- Code: Select all
$i=1; //sets up a counter for the loop
$atrib.$i = "N";
I think the problem lies with ' if(!isset($atrib.$i)', basically what I am trying to do here is say if atrib1 is empty then put a 'N' in as the value for it. Of course each time the loop goes through 'i' will be incremented so the next time we get, if atrib2 is empty then put a 'N' in as the value for it.
Can anyone help me out here?