RE: [PHP] creating skips

From: Date: Fri, 06 Oct 2000 07:22:22 +0000
Subject: RE: [PHP] creating skips
Groups: php.general 
Request: Send a blank email to php-general+get-18844@lists.php.net to get a copy of this message
I have to say that for referential integrity within the database I would only submit upon receiving ALL the information. Carrry information from one page to another inn session variables and apply the insert at the very end. Some people will say that you will be losiing information by ignoring people who drop out halfway through the questionnaire. If the questions are TOTALLY independant then they are right but most questionnaires will have integrated questions that lead on as you go through the questionarre and an uncompleted questionnaire is possibly worse than useless as it may adversely skew the results and it's a common error to put = instead of == in boolean operations. So common it's probably worth writing a homesite script to check that any comparators after an if/while/do are == not = and warn if so... hmm thers an idea........ Tim Parkin Didio -----Original Message----- From: Brian T. Allen [mailto:phplist@gzmarketing.com] Sent: Thursday, October 05, 2000 22:53 To: Rodney Davis; php-general@lists.php.net Subject: Re: [PHP] creating skips 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 -- 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 (#18844) next »