Nodral Posted June 3, 2011 Share Posted June 3, 2011 Hi I'm writing a questionnairre where a user has to answer 50 questions either yes or no. The questions are stored in a db and displayed on screen using an array of questionid -> questiontext. I cna make this display with 2 radio buttons (yes or no) but each one of these lines would need to be an individual form. I would need just one submit button at the end to then write the answers back into my db. How do I make a submit button return several forms? or is there a better way of doing this? <?php $sql="SELECT id, text FROM ls_questions"; $sql=mysql_query($sql); $count=mysql_num_rows($sql); while($row=mysql_fetch_array($sql)){ $all_questions[$row['id']]=$row['text']; } //print them on the screen with a yes/no radio button ?> <p> <table width="80%"> <?php echo "$table_header"; while(list($id, $text)=each($all_questions)){ echo'<tr><form method="POST" action=""><td>' . $text . '</td><td><input type="radio" name="' . $id . '" value="yes"></td><td><input type="radio" name="' . $id . '" value="no"></td></form></tr>'; } ?> <form><input type="submit"></form> Quote Link to comment https://forums.phpfreaks.com/topic/238314-php-survey-tool/ Share on other sites More sharing options...
KevinM1 Posted June 3, 2011 Share Posted June 3, 2011 I don't understand why you'd need multiple forms. An individual form can have an infinite number of inputs. Quote Link to comment https://forums.phpfreaks.com/topic/238314-php-survey-tool/#findComment-1224701 Share on other sites More sharing options...
Nodral Posted June 3, 2011 Author Share Posted June 3, 2011 So how would I have 2 radio buttons for each question so you can only select one of them, but select multiple on the page? Quote Link to comment https://forums.phpfreaks.com/topic/238314-php-survey-tool/#findComment-1224710 Share on other sites More sharing options...
Nodral Posted June 3, 2011 Author Share Posted June 3, 2011 Ignore that last post, I found it. Quote Link to comment https://forums.phpfreaks.com/topic/238314-php-survey-tool/#findComment-1224712 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.