Hello everybody.
I am creating a php page for a company to be able to create surveys into a database and email them to employees. The survey page is going to hit the database and return questions that exist in the table. Most of the questions are multiple choice that have from 4 to 10 possible answers. The table field structure is
question | answer1 | answer2 | answer3 | answer4 | answer5 |
and so on
there will be at least 1 answer for each question but I need to check to see if there is a value present for answer 2 and so on before moving to the next question. How do I check this?
So far I have the following code to display the form
include("connect.inc");
$result = mysql_query("SELECT * FROM survey",$db);
while ($myrow = mysql_fetch_array($result)) {
//Display Question
printf("<TR><TD>%s</TD></TR>\n", $PHP_SELF, $myrow["question"]);
//Display Answers
printf("<TR><TD><input name=\"radiobutton\" type=\"radio\" value=\"%s\"></TD><TD>%s</TD></TR>/n",
$PHP_SELF, $myrow["answer1"], $myrow["answer1"]);
//Display additional answers if they exist
//? ? ? ? ?
And this is where im stumped
How do I check to see if any further answers exist in the array before closing the table, adding the submit button, and ending the form?
My initial thoughts are to start another loop with a if/else involved but i do not know how to check to see if something else exist in the array.
Thank you
G