Re: creating skips

From: Date: Thu, 05 Oct 2000 21:52:46 +0000
Subject: Re: creating skips
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-18774@lists.php.net to get a copy of this message
Just my opinion on both counts: If the questionnaire is of any length at all, do updates along the way. Make all of the pages self-contained, for error checking, so that page 1's form submits to page 1. After there are no errors do the update in the database, and redirect as necessary. If the answer is no, redirect ahead a few pages, if it is yes, go to the next page. Try taking the space out of else if so that it is elseif. Untested and a guess, but that is all that jumped of the screen at me. Oh, wait, a second glance shows me you need to do your compare with ==, not =. }elseif($Q1 == "yes") { should work just dandy. Brian > 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 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#18774) next »