Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have create code to calculate the average of hod score. How do I get the average of score if the user select "N/A", which means the whole rows did not count.

I create a simple formula:-
If user choose rate 5 for 4 question, the final average score will be 5 (5+5+5+5/4).
If user choose rate 5 for 4 question, but 1 question they choose "N/A", means the final score will be 5 too (5+5+5/3), so the other 1 question did not included.

What I have tried:

PHP Code

$ListRate = array(0 => "Please Select", 5 => "5",  4 => "4", 3 => "3", 2 => "2", 1 => "1", 0 => "N/A");

$mySQL2 = 'SELECT A.final_average_score, AVG(B.hod_score) as final_average_score, A.total_score FROM assessment_technical A INNER JOIN assessment_technical_sectiona B WHERE B.assessment_technical_id = '.$data['id'];
$result2 = mysql_query($mySQL2);
	if ($result2){
		if (mysql_num_rows($result2) > 0){
			$row2 = mysql_fetch_assoc($result2);
			$data['final_average_score'] = $row2['final_average_score'];
			$data['total_score'] = $row2['final_average_score']/5*100*0.3;
		}
	}


HTML
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900