0

I am printing question number with the correct answer as 1 and wrong answer as 0.

Now I would like to count how many correct answers for each question.

Example of this:
Question number: 8
00110

For this example there are two correct answer.

$scoree = 0;
		$intt = 0;
		$sqlll=question();
			while($infoo = mysql_fetch_array( $sqlll)) {
		
	  
			echo "<hr><br><strong>{$infoo['Que_ID']}</strong><br />\n";
			$_Session1=$infoo['Que_ID'];
  
		$man=count($_Session1);
			while($infooo = mysql_fetch_array( $man)) {
				$answer1 = $infooo['Que_Answer1'] == $infooo['Ans_Answer1'];
				$answer2 = $infooo['Que_Answer2'] == $infooo['Ans_Answer2'];
				$answer3 = $infooo['Que_Answer3'] == $infooo['Ans_Answer3'];
				$answer4 = $infooo['Que_Answer4'] == $infooo['Ans_Answer4'];
				if ( $answer1 && $answer2 && $answer3 && $answer4)
				{
				echo ("1");
				
	
				}
	
				else
				{
				echo ("0");
				
				}
	
			}
			}
2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by xxreenaxx1
0
SELECT `QuestionId`, `Que_Answer1` + `Que_Answer2` + `Que_Answer3` + `Que_Answer4` + `Que_Answer5` AS Num_Answers FROM table ORDER BY `QuestionId`
0

it prints 00110. Now will I be able to just have the 1 and add them and print this.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.