Jump to content

Php survey tool


Nodral

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/238314-php-survey-tool/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.