Hi,
I have a form with variables names that are created from a loop. This is easily done as the names of the variable are output to the name part of an input field.
however, i now am working on some error checking. I have made a loop that is supposed to loop through the submitted variables and check if each one has a value, if it doesnt have a value then an error message will be created. This is ok if I hard code the variable but i need to do something different.
here is the code I have:
for( $x = 1; $x < $number; $x++ ) {
if(!$odds$x || !$odds$x."a" || !$stake)
{
$fail = "you did not complete all the required fields:<p>";
}
}
Say for example the form I create has 3 rows, that means it will have dynamically created $odds1, $odds1a, $odds2, $odds2a, $odds3 and $odds3a. I now want my for loop to go through these submitted variables and check them. The problem I have is that the way I have written the variables in the code above isnt working, it isnt reading the variables so I am guessing that the problem lies with the $odds$x."a" part.
Can someone help me with this? Its probably something simple.
Thanks.