출력

2013-04-20 6 views
0

나는 다음과 같은 텍스트 파일이 다음 코드는 아래로 끌어와 폼 형식의 텍스트 파일 출력을 읽을출력

$string = 
'1 The most important feature of spiral model is: requirement analysis. risk management. quality management. configuration management 2 The worst type of coupling is: Data coupling. control coupling. stamp coupling. content coupling 3 One of the fault base testing techniques is: unit testing. beta testing. Stress testing. mutation testing 4 A fault simulation testing technique is: Mutation testing. Stress testing. Black box testing. White box testing 5 RS is also known as: specification of White box testing. Stress testing. Integrated testing. Black box testing 6 what is you name: Collins. Achieng. Ogwethi. Kamanda'; 

을 메뉴를 클릭하여 여러 질문을 선택하십시오. 이것은 내가 $ _POST로 출력을 처리하는 다른 PHP 파일로 출력을 제출 할 수 있도록하려는

<html> 
<head> 
<title>read</title> 
</head> 
<body> 
    <b><u> QUESTIONS AND ANSWERS QUIZ</u></b> <br /><br /> 
<?php 
$openFile = fopen("questionandanswers.txt", "r") or exit ("unable to open the text  file"); 
$string = fread($openFile, filesize("questionandanswers.txt")); 

//Regex to get from the first number to the string's end, so we ignore the Number  Question... bit; 
preg_match('/\d.*/', $string, $match); 

//We get all the strings starting with a number until it finds another number (which will be the beginning of another question; 
preg_match_all('/\d\D*/', $match[0], $results); 

$qas = array(); // We prepare an array with all the questions/answers 
foreach($results[0] as $result){ 
//Separating the answer from the string with all the answers. 
list($question, $all_answers) = explode(':', $result); 

//Separating the different answers 
$answers_array = explode('.', $all_answers); 

//Stuffing the question and the array with all the answers into the previously prepared array; 
$qas[] = array('question' => $question, 'answers' => $answers_array); 
} 
?> 
<form name="processor" action="processor.php" method="post"> 
<?php 
//Looping through the array and outputting all the info into a form; 
foreach($qas as $k => $v)?> 
echo "<label>{$v['question']}</label><br/>"; 
echo "<select name='answers[]'>"; 

//we loop through $v['answers'] because its an array within the array with all the answers. 
foreach($v['answers'] as $answer) 
{ 
    echo "<option>$answer</option>";//the output 
} 
echo "</select>"; 
echo "<br/><br/>"; 
?> 
<input type="submit" value="Submit"> 
</form> 
</body> 
</html> 

, 그것에 대해 이동하기 위해 노력하고있어 방법이다. 이걸 통해 나를 도울 수있는 사람? 당신이 다음 배열로 모든 대답을 선택할 수있을 것입니다 processor.php 파일에서

echo "<select name='answers[]'>"; 

:

echo "<select>"; 

에 :

답변

0

내가 방금이 줄을 해결하는 데 생각

var_dump($_POST['answers']) 

하지만이 줄은 문서 모델을 손상시킬 수 있으므로 다시 생각해보십시오.

<input type="text" name="question" value="<? 
+0

통찰력을 가져 주셔서 감사합니다. 제 코드와 어떻게 통합 될지 모르지만, 같은 것을 통합하는 데 도움주세요. 강조 표시된 수정 사항을 입력 한 후에도 여전히 동일한 오류가 발생합니다. 고맙습니다. –

+0

오류의 이름을 붙일 수 있습니까? – xsign

+0

이전에 만든 양식을 지우고 브라우저에 표시된 일부 코드와 함께 왜곡 된 양식을 표시합니다. 정확한 출력을 볼 수 있도록 여기에 어떻게 연결할 수 있는지 모르겠지만 내 로컬 서버에서 실행하려고하면 어떻게되는지 설명 할 수 있습니다. –