chestnuth Posted February 4, 2008 Share Posted February 4, 2008 Hi guys, i have a problem regarding the naming of a text box. I am trying to create a php page that brings back a list of questions in my database table --> (qid (pk), question, active), only if active is marked as YES. The questions are displayed on the screen using a while loop because there are an unknown amount that could come from the DB. Each question should have a textbox with it, which allows the user to enter the answer. When then user is happy with the answer it should then take the data from the textbox and the qid of the question and insert it into a another table. I can do this fine if the amount of questions are static, but because the amount can vary i cant work out how to pick up the data, and i dont know what each text box will be called. i have currently got the following while loop: <?php while($rowactivequestions=mysql_fetch_array ($resultactivequestions)) { echo $rowactivequestions['question']; ?> <br /> <textarea name='answer' rows="5" cols="70">Answer.</textarea> <br /> <br /> <?php } ?> Is there any way that i can give the text box a dynamic number and also be able to pick the textbox name up, the question number (qid), and also the text the user enters, and post this to a script that inserts it into the database? Any ideas would be gratefully received!!! Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/89396-database-dilemma/ Share on other sites More sharing options...
revraz Posted February 4, 2008 Share Posted February 4, 2008 You can use an array and then just loop through the entire array. Quote Link to comment https://forums.phpfreaks.com/topic/89396-database-dilemma/#findComment-457782 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.