Welcome Guest, Not a member yet? Register   Sign In
Get position (rank) based on subject score
#1

I have a working function in my model where I'm trying to get the position of students in a class-based 
on their subject scores.
The problem is that the where clause isn't filtering results to classify them based on subjects.
please help me solve this

model:
PHP Code:
public function GetSubjectPosScores($exam_group_class_batch_exam_subject_id
    {
        $this->db->order_by('get_tot_score''DESC');
        $this->db->select('get_tot_score');
        $this->db->where('exam_group_class_batch_exam_subject_id'$exam_group_class_batch_exam_subject_id);
        return $this->db->get('exam_group_exam_results')->result(); 
    


controller:
PHP Code:
public function GetSubjectPosScores($exam_group_class_batch_exam_subject_id)
    {
        $data $this->examresult_model->GetSubjectPosScores($exam_group_class_batch_exam_subject_id); 
        return $data;
    

view:
PHP Code:
<td style="border: 1px solid black; font-size:15px;font-weight:bold;width:40px;text-align:center;color:black;"> <?php
                              $scores2 
$CI->GetSubjectPosScores($exam_result_value->exam_group_class_batch_exam_subject_id); //echo $value->pos;
                            $scores array_column($scores2'get_tot_score');
                            $pos array_search($exam_result_value->get_tot_score$scores);

                                                $number $pos 1;
                                  echo $CI->ordinal($number);

                                                ?></td> 


thank you. 
Reply
#2

Move your order_by below your where order_by should be the last statement before retrieving the record with get.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB