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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.