I have a bunch of questions for users listed in an xml file (along with other stuff). i use simplexml_load_file to load the xml then php displays the first question in the xml file and generates a form with which users can give their answer to that question. when the form is submitted, those answers are saved somewhere else, a counter advances one click and the same page is then displayed again with the intention that the next question in the xml file (referenced by the counter) will be displayed.
Thing is, it all works fine the first time but second time round, nothing from the xml file gets displayed. But I dont get an error saying that the xml file has not loaded. What is happening?
Here is simplified code (in test.php):
trigger_error('Error reading XML file',E_USER_ERROR);
//get number of last question
$questionNumber = 0;
$question = $xml->question[$questionNumber];
//its the second bit of this that displays nothing second time around but should display text of second question
echo "The question number is $questionNumber. The question is $question->text";
echo "<form action = 'test.php' method ='post'>";
echo "<input name='newQuestionNumber' type ='hidden' value=$questionNumber>";
echo "<input type='submit' value = 'Submit'>";
The test.xml looks like this:
<text>yet another question?</text>
I am new to all this so please be gentle with me!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)