PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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.
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?
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.
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.