1

I retrieved data from database, then I find average for use to find position of different of the student but I need to find rank by looking class, year and term like that

for the first term

  year term  class  student name    average   position   
  2016  I     1      Julius           90        1
  2016  I     1      Anna             85        2
  2016  I     1      alexander        70        3
  2016  I     2      mary             84        1
  2016  I     2      Winnie           76        2 

And for the second term

  year term  class  student name    average   position   
  2016  II     1      Julius           87        2
  2016  II     1      Anna             83        3
  2016  II     1      alexander        96        1
  2016  II     2      mary             84        2
  2016  II     2      Winnie           98        1 

The area I stacked the average which used is the calculate is not retrieved from the database(I retrieve the marks and then I find total and average then I store by array)

 $average = $total/$tot_subject;

I tried to do use this but I failed;

if($form1 = $form && $year1 = $year && $term1 = $term) {    
 arsort($average);  

 foreach($average as $key => $value) { 
     sort($average);

     $max = max($average);
     $keys = array_search($max, $average);    
     unset($average[$keys]);

    if(sizeof($average) >= 0)
       if(!in_array($max,$average))
       $i++;    
    }
  }
 } 
Timothy
  • 2,004
  • 3
  • 23
  • 29
Rmoses
  • 11
  • 1

0 Answers0