I'm trying currently to insert back into a database values from my form.
<?php do { ?>
<tr>
<td><?php echo $row_questions['question']; ?><br /><table><tr><td style=
"padding:15px; text-align:center">
<label>
<center><input type="radio" name="answers_<?php echo $row_questions['id']; ?>_<?php echo $row_questions['sub_category']; ?>" value="1" id="answers_1" /></center><br />
Low</label>
</td><td style="padding:15px; text-align:center">
<label>
<center><input type="radio" name="answers_<?php echo $row_questions['id']; ?>_<?php echo $row_questions['sub_category']; ?>" value="2" id="answers_2" /></center><br />
Fairly Low</label>
</td><td style="padding:15px; text-align:center">
<label>
<center><input type="radio" name="answers_<?php echo $row_questions['id']; ?>_<?php echo $row_questions['sub_category']; ?>" value="3" id="answers_3" /></center><br />
Average</label>
</td><td style="padding:15px; text-align:center">
<label>
<center><input type="radio" name="answers_<?php echo $row_questions['id']; ?>_<?php echo $row_questions['sub_category']; ?>" value="4" id="answers_4" /></center><br />
Fairly High </label>
</td><td style="padding:15px; text-align:center">
<label>
<center><input type="radio" name="answers_<?php echo $row_questions['id']; ?>_<?php echo $row_questions['sub_category']; ?>" value="5" id="answers_5" /></center><br />
High</label>
</td></tr></table><br />
</tr>
<?php } while ($row_questions = mysql_fetch_assoc($questions)); ?>
the form gets the questions from a table in my database (called questions). they are in three categories and only one categories set of questions is pulled at any one time.
I need to insert each answer individually into another table (called user_answers).
I'm having trouble working out quite how to go about this and it's beginning to do my head in!
the form manages to pass through $_POST a value that when I print_r($_POST); I get
Array ( [answers_90_5] => 3 [answers_91_5] => 3 )
With 90 & 91 being the question ids and 5 being the subcategory in both instances.
From here I am stumped.
How do I identify these parts of each individual post along with the answer and insert them as a row each in the table?
I'm fine with doing the MySQL insert normally and a standard form passing values etc. but I'm completely stumped on how to do this!
Many thanks in advance!
while($row = ...) { ... }loop instead.