わかった。私はほとんどそれを手に入れました。ループの問題があります。PHP 側をじっと座ってユーザーの応答を待つことができません。isset を試してみましたが、まだ続きます。ここにコードを貼り付けます。それが大丈夫であることを願っています。複数の選択肢として基本的にrow = 4からプルしているExcelスプレッドシートを選択すると、選択した列が見つかり、行を下って次の行に質問します...申し訳ありませんが、これは初心者だと知っています町ですが、フィードバックを本当に感謝しています。
<HTML>
<HEAD>
<title>
</title>
</head>
<body>
<?php
// include class file
include 'Excel/reader.php';
// initialize reader object
$excel = new Spreadsheet_Excel_Reader();
// read spreadsheet data
$excel->read('Question-Flow.xls');
$x = 4; //Row
$y = 0; //Column @ 0 for 1st iteration
$questions = array(); //Stores questions and ends in 'STOP'
//Iterates down a row until $cell='SUBMIT'
do {
//Populates $questions() and iterates until $cell='STOP'
do {
$y++;
$cell = isset($excel->sheets[0]['cells'][$x][$y]) ? $excel->sheets[0]['cells'][$x][$y] : '';
if ($cell){
//Populates $questions array with active cells
array_push($questions, $cell);
}
} while ($cell != 'STOP');
for ($i=0; $i < count($questions)-1; $i++){
//echo "<input type=radio name=$i value=\"".$questions[$i]."\">".$questions[$i]."<br>";
?>
<HTML><BODY>
<form action="index.php" method="post">
<input type=submit name=choice value=<?php echo $questions[$i]; ?> style="width: 100px; height: 100px;"><br>
</form>
</BODY></html>
<?php
//Move $cell back one from 'STOP'
$y--;
$cell = isset($excel->sheets[0]['cells'][$x][$y]) ? $excel->sheets[0]['cells'][$x][$y] : '';
$choice = $_POST['choice'];
if(isset($_POST['choice'])){
echo $choice;
echo $cell;
echo $x;
echo $y;
}
}
while($choice != $cell){
//Iterate back to find $choice
$y--;
$cell = isset($excel->sheets[0]['cells'][$x][$y]) ? $excel->sheets[0]['cells'][$x][$y] : '';
}
//Moves to next row of Questions
$x++;
//Populates $cell with 'SUBMIT' or prompts next question
$cell = isset($excel->sheets[0]['cells'][$x][$y]) ? $excel->sheets[0]['cells'][$x][$y] : '';
} while ($cell != 'SUBMIT');
?>
</body>
</html>
迷っています。私はPHP、javascript、HTMLが初めてなので、ばかげた質問を許してください。Excelファイルからの文字列が取り込まれたこの配列があります。プリントはこんな感じ
Array ( [0] => Question1 [1] => Question2 [2] => Question3 [3] => STOP )
これらの値のそれぞれをユーザーに質問として提示し、ユーザーに選択させる必要があります。次に、ループに戻って、Excel から新しい値を入力し (これですべて完了です)、その配列に戻って新しい質問をする必要があります。彼らが選択した「セル」のExcelループにフィードするための回答を保存する必要があります。それは質問の分岐ツリーのようなものです。
何らかのタイプの入力フォームを以下の for ループに入れることができれば、それは正しく機能しますか? かかりませんが。
for ($i=0; $i < count($questions); $i++){
echo $i; //echo'd just to see the count and it's correct
}