chestnuth Posted March 6, 2008 Share Posted March 6, 2008 Hi guys, I have a bit of a problem with reading values out of a text box, any help would be great! The while loops goes through a db table and passes out all the rows onto a form. Each row is a question that i need a answer from the user for so there is a text area associated with each question. like this: <?php while($rowactivequestions=mysql_fetch_array ($resultactivequestions)) { $textareaid='Q'.$rowactivequestions['qid']; $names.=$textareaid.' '; echo $rowactivequestions['question']; echo '<br />'."\n"; echo '<textarea name="'.$textareaid.'" rows="5" cols="70">Answer.</textarea>'."\n"; echo '<input type="type" name="thenames" value="'.$names.'"/>'."\n"; echo '<br />'."\n"; echo '<br />'."\n"; } ?> As the questions id's could be different every time the form loads i need to insert the question number and also the associated answer (from textarea) into the database. As you can see the second input is where i am storing the question id values from the database, it looks something this at the moment (Q1, Q2, Q3, Q5) question 4 is missing as it does not satisfy the query that produces the list of questions. how can i get each value (question id) from the textbox and also each answer from the text area and insert them to the database? This has been annoying me for weeks. any help would be great Thanks J Link to comment https://forums.phpfreaks.com/topic/94725-textbox-values/ Share on other sites More sharing options...
amites Posted March 6, 2008 Share Posted March 6, 2008 generate the name of each text box from the number of the question, ex: while ($row = mysql_fetch_assoc($result)) { echo $row['question'].' <input type="text" name="'$row['id'].'" /><br />'; } make sense? Link to comment https://forums.phpfreaks.com/topic/94725-textbox-values/#findComment-485595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.