Online Survey Form loop question [SOLVED]
Posted: Thu Aug 16, 2012 5:11 pm
I am a super newby...
I created an online survey. The questions are stored in the database. I created the form below, but cannot figure out how to get the loop to run and have ONE SUBMIT button. Can figure out how to take it outside of the loop...
HELP!
I created an online survey. The questions are stored in the database. I created the form below, but cannot figure out how to get the loop to run and have ONE SUBMIT button. Can figure out how to take it outside of the loop...
HELP!
Code: Select all
<?php
/* ################################ */
/* ###### Sandbox Document ######## */
/* ################################ */
/* ################################ */
/* #### Get Survey Questions ###### */
/* ################################ */
function getQuestions($dbc) {
$query = "SELECT * FROM survey_questions";
$result = mysqli_query($dbc, $query);
if ($result) {
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$qNum = $row['question_id'];
$body = $row['question_body'];
echo '
<div class="entry">
<span class="qTitle">'. $qNum . '. ' . $body.'</span>
<form action="index.php" method="post">
<input type="text" name="answer" size="5" />
<input type="submit" value="Submit" name="submit" />
<input type="hidden" name="questionid" value="questionid" />
<input type="hidden" name="submitted" value="1" />
</form>
</div>'
} //END if
} //END while
} //END function getQuestions
?>