I have PHP radio buttons being generated by the following code:
while($a_row = mysql_fetch_array($answers_result))
{
// print each answer choice
?>
<input type='radio' name='question_<?php echo $current_question['id'] ?>'
value='<?php echo $a_row['prompt']?>'><?php echo $a_row['prompt']?>
<br />
<?php
}
I am then defining the user’s choice with this code:
$user_answer = $_POST["question_{$_SESSION['current_question']['id']}"];
However, this isn’t always returning the value, which should be whatever $a_row[‘prompt’] is.. If it is the first radio button in the list, it returns “answer 1”, etc.. It is not getting the correct values from my sql table. Am I doing something wrong in my code that is causing it to not actually get the “value” of each radio button when the user selects it and submits the form?
You need to escape the ‘ ‘ as you start with them
Also note that your need to finish your PHP command with ; that not the case.
To avoid ‘ ‘ trouble I recompend using ” ” when you know that you will have to add some ‘ ‘ in your code, that way they do not interfere.