Hi I am trying to make a form sticky. It creates a grid, and the user can then select a value for each row.
$subjectListArray has values of subject names like 'english', 'maths','speaking and listening' and $gradeSetArray carries a selection of grades like a,b,c etc
When I press submit I want the values that were selected to stay selected.
It works fine for subjects with NO SPACES in their names. As soon as I introduce an array value like 'Speaking and listening' its not sticky.
SO the space is causing me a problem.
<form>
<?php
foreach ($subjectListArray as $subject){
echo "<tr><td>$subject</td>";
foreach ($gradeSetArray as $grade){
echo '<td><input type="radio" name="'.$subject.'" value="'.$grade.'" ';
if ( isset($_POST[$subject])and $_POST[$subject]==$grade){
echo 'checked="checked"';
}
echo ' /></td>';
}
echo "</tr>";
}
?>
<input type="submit" name="submitPupilData" value="Input data" />
</form>
Here's a little of the html produced:
<td>
<input type="radio" value="p2iic" name="Speaking and Listening">
</td>
So for some reason my if ( isset($_POST[$subject])and $_POST[$subject]==$grade) isn't working if there's a space
What can I do in order to keep the spaces in the names and keep the from sticky?
Thanks
As per Jakar I printed out the $_POST and I noticed that the spaces were being replaced by _ characters thus Array ( [Health_and_well_being] => p2iic