First thanks to all the ideas for reading one word from a file, but I
hit another snag.
Here is what I am trying to accomplish.  I have a text file
(questionFile.txt) and it contains questions that can be arranged like:
1.  Question One
A1.  Question OneA
C.  Question Three
For this email, I will call the 1.  A1.  C. all question numbers.
So my first php script reads this file and for each question it creates
a place for a user to enter the answer and each answer input has should
have a name that correspondes to each question number (e.g. 1.  A1. C.
or whatever comes before the period).  So the code that does this is
($wd is the file that contains the questions):
 while(!feof($wd) )
 {
      $question = trim( fgets($wd, 4096) );
      if (strlen($question))
  {
       $questionWordArray = explode(" ", $question);
       $currentQuestionNumber = $questionWordArray[0];
       //$questionNumberArray[$questionCounter]=$currentQuestionNumber;
       echo "$question  <input NAME=\"$currentQuestionNumber\"><br>";
       //echo "<input type=\"hidden\"
name=\"questionNumberArray[$questionCounter]\"
                value=\"$questionNumberArray[$questionCounter]\">";
       $questionCounter++;
      }
 }
Then once the user enters answers to the questions he or she knows, they
hit the submit button and my second script takes that data, writes it to
the answer file and displays all the other answers that people have
entered for these questions.  I was trying to get the answer file to be
written in the following manner:
1.  First person that answers questoin 1
A1.  First person that answers question A1
1.  Second person that answers question 2
C.  first person to answer question C.
Then for displaying the questions and all the answers for that
questions, I was having the second script, print the first question and
then compare the first question's question number to each of the
question numbers in the answer file and if they match then it prints
that answer and continues to search for more answers for that question.
My problem is in writing this answer file.  Since the name of the input
field for the questions is the question Numbers, I don't see how to
differentiate the value contained in $currentQuestionNumber.
$currentQuestionNumber is the name of each of the input fields and it
also should contain the data that the user enters for the answer to the
question.  When I am trying to write the answer file, I am not sure how
to get access to the answer the user put in, when I try to just write
$currentQuestionNumber for each of the questions, it just writes 1.  1.
A1.  A1.
C.  C.
instead of
1.  Answer 1 here
A2.  Answer A2 here
C.  Answer C here.
I was playing around with putting all the $currentQuestionNumber into an
array (as you can see from the commented out section) in hopes that then
I could use those to refer to the actual answer but that didn't work.
So how would you go about doing this?
---Andrew V. Romero
If you want to reply personally, remove all numbers from my address.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to