creating skips
| From: | Rodney Davis | Date: | Thu, 05 Oct 2000 21:39:19 +0000 |
| Subject: | creating skips | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18773@lists.php.net to get a copy of this message | ||
I am trying to create a questionaire and capture that data and
sticking it into a MySql database. One question will appear at a
time on the page and will include skips. Meaning that should
a person answer "no" he would skip ahead several questions or
if he where to say "yes" the next question in line would appear.
My questions are two fold.
1. Should I make inserts into the database at each iteration
or should I carry the variables through to the end and make
one insert statement after the questionaire has been
completed?
2. Can anyone look at the following code and give me a hint as to
why after submiting the form at the top the second question is
not displayed. Looking at the URL, "Q1" is being passed "=yes"
why would this script fail to move to the next else if statement?
function questionaire () {
if (!isset ($Q1)) {
echo ("<form action=\"$PHP_SELF\">");
echo ("<p>1.過去5年間(1996-2000年)に海外旅行はされましたか?
</p>\n");
echo ("$Q1");
echo ("<p><center>はい<input type=\"radio\" name=\"Q1\"
value=\"yes\">");
echo ("いいえ<input type=\"radio\" name=\"Q1\"
value=\"no\">");
echo ("<input type=\"hidden\" name=\"position\"
value=\"process\">");
echo ("<input type=\"submit\">\n</center></p>\n");
echo ("</form>");
} else if ($Q1 = "yes") {
echo ("<form action=\"$PHP_SELF\">\n");
echo
("<p>2.過去5年間(1996-2000)に海外旅行された回数は?</p>");
echo ("<select name=\"Q2\">");
echo ("<option value=\"1\">1</option>");
echo ("<option value=\"2\">2</option>");
echo ("</select>");
echo ("<input type=\"hidden\" name=\"position\"
value=\"process\">");
echo ("<input type=\"submit\">\n</center></p>\n");
echo ("</form>");
}
}
Thanks in advance.
rodney davis