Page 1 of 1

form processing question

Posted: Fri Jun 17, 2005 10:29 am
by nwhaley
Hey everyone I just started working with PhP a few days ago and its been a while since I actualy got to do any real coding in my worklife so I'm a little rusty and was wondering if anyone could help me out. I'm currently working on a quizzing application using PhP to pull the questions ands answers from a database that I already have setup.

I made a system DNS connection to the database and I am using PhPs ODBC functions to access it. what I'm having it do is look at the marker in the question that determines if its a multiple choice question or single answer question and dynamically make a form with the question and answers in radio button format for single answer and checkbox format for multiple answer. All of this is working fine so far save one thing. I need it to print out one question and one set of answers then wait for the user to hit the submit button before going into and printing the next question.

That way if the question has a wrong answer I can bring up a new browser window giving them the answer and referance pages to look at and then print out the next question and series of answers. I thought about using an if statment something similar to the following.

Code: Select all

if($i < $rowcount and $proceed = 1)
where "i" would be a generic counter and rowcount the total count of rows pulled from the SQL query. proceed would initally be set to 1 to enter the if statement the first time then set to 0 inside and would only go back to 1 if submit was pressed. This way I can guarantte it runs at least once.The issue is I think this would "only" execute once then drop out and a do while loop dosent look like it would work either because theres no way of stopping it. is there any kind of and I hate to even say this "goto" statement in PhP that I can use to just move my marker back up to a previous code line as a source of flow control?

Posted: Fri Jun 17, 2005 11:29 am
by nwhaley
no one has any ideas on this? I thought at least someone would have an idea of how to control output based on waiting for user input.

Re: form processing question

Posted: Fri Jun 17, 2005 11:42 am
by Chris Corbyn
nwhaley wrote:is there any kind of and I hate to even say this "goto" statement in PhP that I can use to just move my marker back up to a previous code line as a source of flow control?
I read that post 3 times and still not sure of what you're trying to do but anyway :?

"goto" - Maybe if you put your code into functions then all you have to do is make a call to the appropriate function rather than getting the script to go backwards.

Posted: Fri Jun 17, 2005 11:54 am
by nwhaley
ahh that explains the lack of responses my apologies. What I'm trying to do is get the app to pull one question and one set of answers and print them, wait for the user to chose their answer then when they hit submit pull up the "next" question and answer set. The part I'm having trouble with is pausing the processing of the loop till the user hits the submit button. Though your most likely right if I can find some way to make it not exit the function till the submit button is pressed that may exert the kind of control I need to make the rest of it work.

Posted: Sat Jun 18, 2005 10:27 am
by dreamline
If i'd do that same line it would be something like this:

Code: Select all

if(($i < $rowcount) && ($proceed == 1)) {
//rest of stuff
}
else {
//More stuff
}
JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sat Jun 18, 2005 2:45 pm
by John Cartwright
dreamline: Read the link in my thread called Posting Code in the Forums please.
Getting tired of fixing your posts.

Posted: Sat Jun 18, 2005 9:42 pm
by dreamline
Oops sorry jcart, my bad.. Won't happen again.. :)