<?php
$answer1 = 'question-1-answers';
$answer2 = 'question-2-answers';
$answer3 = 'question-3-answers';
$answer4 = 'question-4-answers';
$answer5 = 'question-5-answers';
$answer6 = 'question-6-answers';
$answer7 = 'question-7-answers';
$answer8 = 'question-8-answers';
$answer9 = 'question-9-answers';
$answer10 = 'question-10-answers';
$_SESSION["counter"] = 0;
if ($answer1 == "a")
{
$_SESSION["counter"]++;
}
if ($answer2 == "a")
{
$_SESSION["counter"]++;
}
if ($answer3 == "a")
{
$_SESSION["counter"]++;
}
if ($answer4 == "a")
{
$_SESSION["counter"]++;
}
if ($answer5 == "a")
{
$_SESSION["counter"]++;
}
if ($answer6 == "d")
{
$_SESSION["counter"]++;
}
if ($answer7 == "c")
{
$_SESSION["counter"]++;
}
if ($answer8 == "c")
{
$_SESSION["counter"]++;
}
if ($answer9 == "b")
{
$_SESSION["counter"]++;
}
if ($answer10 == "b")
{
$_SESSION["counter"]++;
}
?>
因此,這段代碼是爲我的測驗評分,並將正確答案的數量(最初爲0)傳遞到下一頁。問題是,當我運行我的代碼時,無論我得到多少正確答案,正確答案的數目總是爲0。有什麼建議?我的測驗分級算法有什麼問題?
<p>
5.What is the country with the highest Muslim population?
</p>
<div>
<input type="radio" name="question-5-answers" id="question-1-answers-a" value="a" />
<label for="question-1-answers-a" class="fwrd LabelA">a-Indonseia</label>
</div>
<div>
<input type="radio" name="question-5-answers" id="question-1-answers-b" value="b" />
<label for="question-5-answers-b" class="fwrd LabelA">b-Pakistan</label>
</div>
<div>
<input type="radio" name="question-5-answers" id="question-1-answers-c" value="c" />
<label for="question-5-answers-c" class="fwrd LabelA">c-Saudi arabia</label>
</div>
<div>
<input type="radio" name="question-5-answers" id="question-1-answers-d" value="d" />
<label for="question-5-answers-d" class="fwrd LabelA">d-India</label>
</div>
<br/>
你貼本已http://stackoverflow.com/q/43557475/1415724 - 要是我事先知道,我的關閉它作爲一個精確的副本。 –
@Fred -ii:我做到了,但是採用了完全不同的方法。如果你有麻煩閱讀它,你會知道。 – mdot