Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

CODEIGNITERAveragebetween2columns

pic1 SQL CODE --> SELECT ((nota_sust + nota_intreb) / 2) AS media_comisie from subject.

I need to put this in my controller and i don't know how to do it to show up my results in the column ( media_comisie) then i need to show up on my page I'm using codeigniter. My controller:

function subject($param1 = '', $param2 = '' , $param3 = '')
{
    if ($this->session->userdata('admin_login') != 1)
        redirect(site_url('login'), 'refresh');
    if ($param1 == 'create') {
        $data['name']       = $this->input->post('name');
        $data['class_id']   = $this->input->post('class_id');
        $data['year']       = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description;
        if ($this->input->post('student_id')!= null) {
            $data['student_id'] = $this->input->post('student_id');
            $data['teacher_id'] = $this->input->post('teacher_id');
            $data['nota_conducator'] = $this->input->post('nota_conducator');
            $data['media'] = $this->input->post('media');
            $data['plagiat'] = $this->input->post('plagiat');
            $data['nota_sust'] = $this->input->post('nota_sust');
            $data['nota_intreb'] = $this->input->post('nota_intreb');

        }

        $this->db->insert('subject', $data);
        $this->session->set_flashdata('flash_message' , get_phrase('data_added_successfully'));
        redirect(site_url('admin/subject/' . $data['class_id']), 'refresh');
    }

THE PAGE TO SHOW THE RESULTS

<table class="table table-bordered datatable" id="table_export">
                <thead>
                    <tr>
                        <th rowspan="2"><div>#</div></th>
                        <th rowspan="2"><div><?php echo get_phrase('GRUPA');?></div></th>
                        <th rowspan="2"><div><?php echo get_phrase('NUMELE, PRENUMELUI ABSOLVENTULUI');?></div></th>
                        <th rowspan="2"><div><?php echo get_phrase('TEMA LUCRĂRII DE DISERTAŢIE');?></div></th>               
                        <th colspan="2"><div><?php echo get_phrase('CONDUCĂTOR');?></div></th>
                        <th rowspan="2"><div><?php echo get_phrase('MEDIA ABS.');?></div></th>
                        <th rowspan="2"><div><?php echo get_phrase('PLAGIAT [%]');?></div></th>
                        <th colspan="3"><div><?php echo get_phrase('NOTE DATE DE FIECARE MEMBRU AL COMISIEI');?></div></th>
                        <th rowspan="2"><div><?php echo get_phrase('OPȚIUNI');?></div></th>


                    <tr>
                        <td><div><?php echo get_phrase('NUME');?></div></td>
                        <td><div><?php echo get_phrase('NOTĂ');?></div></td>
                        <td><div><?php echo get_phrase('NOTĂ SUST.');?></div></td>
                        <td><div><?php echo get_phrase('NOTĂ ÎNTREB.');?></div></td>
                        <td><div><?php echo get_phrase('MEDIA COMISIE');?></div></td>
                    </tr>
                </thead>
                <tbody>
                    <?php $count = 1;
                    $subjectss = $this->db->query('SELECT ((nota_sust + nota_intreb) / 2) AS average from subject');
                        foreach($subjects as $row):?>

                    <tr>
                        <td><?php echo $count++;?></td>
                        <td><?php echo $this->crud_model->get_type_name_by_id('class',$row['class_id']);?></td>
                        <td><?php echo $this->crud_model->get_type_name_by_id('student',$row['student_id']);?></td>
                        <td><?php echo $row['name'];?></td>
                        <td><?php echo $this->crud_model->get_type_name_by_id('teacher',$row['teacher_id']);?></td>
                        <td><?php echo $row['nota_conducator'];?></td>
                        <td><?php echo $row['media'];?></td>
                        <td><?php echo $row['plagiat'];?></td>
                        <td><?php echo $row['nota_sust'];?></td>
                        <td><?php echo $row['nota_intreb'];?></td>
                        <td><?php echo $row['average'];?></td>

Comments