Hi,
I am trying to save response out of HTML form which has about 100questions. In question user has to select 1 option, out of three.Now the Objective is to save the responses of the user, so we admin can view them later.I am more interested in their actual response rather than values field. my HTML form goes something like this:
Now,to keep track of the actual answers I created an array which hold all the questions and their 3 respective options:
also, there $_POST array
Now, what I want is to match $_POST array's [question-15-answer] value with $questions array's [question-15-answer] value and store that somewhere e.g database table. so admin that view them later. Also, need to ignore the order field on $_POST array but that's not important.
Hoping to find some php coders, so you can guide me as I just started coding with php(4-5days back):ashamed:
{edit}
I need something like this but not sure How do I loop over this:
--- Updated Post - Automerged ---
Nobody into php?
anyways, I figured it out
I am trying to save response out of HTML form which has about 100questions. In question user has to select 1 option, out of three.Now the Objective is to save the responses of the user, so we admin can view them later.I am more interested in their actual response rather than values field. my HTML form goes something like this:
PHP:
<form method="post" action="save.php">
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
<tr>
<td colspan="3">Â </td>
</tr>
<tr>
<td width="160" valign="top">
[b]Select the most appropriate option[/b]
<table border="0">
<tr><td rowspan="4">
<table border="0">
<tr><td><input type="hidden" name="question-15-order" value="0" /><input type="radio" name="question-15-answer" value="1" /></td><td>I like new ideas when they have practical applications.</td></tr>
<tr><td><input type="radio" name="question-15-answer" value="2" /></td><td>I fall in love with new ideas and concepts for their own sake.</td></tr>
<tr><td><input type="radio" name="question-15-answer" value="3" /></td><td>I'm really in between.</td></tr>
</table>
<table border="0">
<tr><td><input type="hidden" name="question-11-order" value="0" /><input type="radio" name="question-11-answer" value="1" /></td><td>I am a mixer and mingler at parties.</td></tr>
<tr><td><input type="radio" name="question-11-answer" value="2" /></td><td>I prefer one-on-one conversations.</td></tr>
<tr><td><input type="radio" name="question-11-answer" value="3" /></td><td>I'm really in between.</td></tr>
</table>
<snip>
......and so on
Now,to keep track of the actual answers I created an array which hold all the questions and their 3 respective options:
PHP:
$ questions = Array(
[question-15-answer] => Array
(
[1] => I like new ideas when they have practical applications.
[2] => I fall in love with new ideas and concepts for their own sake.
[3] => I am really in between.
)
[question-11-answer] => Array
(
[1] => I am a mixer and mingle at parties.
[2] => I prefer one-on-one conversations.
[3] => I am really in between
)
<snip>
......and so on
also, there $_POST array
PHP:
Array
(
[question-15-order] => 0
[question-15-answer] => 3
[question-11-order] => 0
[question-11-answer] => 3
<snip>
......and so on
Now, what I want is to match $_POST array's [question-15-answer] value with $questions array's [question-15-answer] value and store that somewhere e.g database table. so admin that view them later. Also, need to ignore the order field on $_POST array but that's not important.
Hoping to find some php coders, so you can guide me as I just started coding with php(4-5days back):ashamed:
{edit}
I need something like this but not sure How do I loop over this:
PHP:
$selected = $_POST[$value];
$choice = $questions[$key][$selected];
echo $choice;
--- Updated Post - Automerged ---
Nobody into php?
anyways, I figured it out