我有一個表question_attempts
。該表具有兩列rightanswers
和youranswer
。從兩列使用條件相同的記錄計數
我想獲得記錄數rightanswer
= youranswer
。這實際上是我的整個代碼。
$quizsections = mysql_query("SELECT * FROM quiz_sections");
while($quizsectionsrslt = mysql_fetch_array($quizsections)){
$quizsectionsid = $quizsectionsrslt['id'];
$quizsectionsheading = $quizsectionsrslt['heading'];
$quizsectionsquizid = $quizsectionsrslt['quizid'];
$quizsectionsfirstslot = $quizsectionsrslt['firstslot'];
echo $quizsectionsheading."<br />";
$quizslots = mysql_query("SELECT * FROM quiz_slots WHERE `quizid`=$quizsectionsquizid LIMIT ".($quizsectionsfirstslot-1).", 10");
while($quizslotsrslt = mysql_fetch_array($quizslots)){
$quizslotids = $quizslotsrslt['questionid'];
$questions = mysql_query("SELECT * FROM question_attempts WHERE `questionid`=$quizslotids");
$num_rows = mysql_num_rows($quizslots);
while($answercount = mysql_fetch_array($questions)){
$answercountrslt = $answercount['questionid'];
echo $rightanswer = $answercount['rightanswer'];
echo $youranser = $answercount['responsesummary']."<br />";
//Here want to display the count of rightanswer and count of wrong answer.
}
}
echo "Total Questions : ".$num_rows."<br /><br />";
}
得到了我的要求的結果。 – Raja