lukep11a Posted June 23, 2012 Share Posted June 23, 2012 Hi, I am trying to get a specific part of my form to remember the selections by the user if the form fails the validation process. As it stands when the form is processed, $team_id is passed as an array as the user is required to make 11 selections. I think the reason why it is failing to remember the selections is because it is an array. I am not sure this is even possible but if anyone has any ideas I would be very grateful, the code I have currently is below: <tr> <td>'. $row['team_name']. '</td> <td>?'. $row['value']. 'm</td> <td><input type="radio" name="team_id['. $row['selection_group']. ']" id="'. $row['value']. '" value="'. $row['team_id']. '"' ?><?php if ($_POST['team_id[$group]'] == '$team_id') echo ' checked="checked" ' ?><?php echo '/></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/264662-php-sticky-forms/ Share on other sites More sharing options...
Pikachu2000 Posted June 23, 2012 Share Posted June 23, 2012 You have quoting issues in this part. Variables aren't interpolated within single quotes. <?php if ($_POST['team_id[$group]'] == '$team_id') Quote Link to comment https://forums.phpfreaks.com/topic/264662-php-sticky-forms/#findComment-1356424 Share on other sites More sharing options...
Barand Posted June 23, 2012 Share Posted June 23, 2012 Also, It should be $_POST['team_id'][$group] Quote Link to comment https://forums.phpfreaks.com/topic/264662-php-sticky-forms/#findComment-1356500 Share on other sites More sharing options...
lukep11a Posted June 24, 2012 Author Share Posted June 24, 2012 Thank you both got it working with your suggestions, much appreciated! if ($_POST['team_id'][$group] == $team_id) echo ' checked="checked"' Quote Link to comment https://forums.phpfreaks.com/topic/264662-php-sticky-forms/#findComment-1356593 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.