Student table

Result table

MY Question: Student table join result table ,but same student name display multiple, so My question I have same student display once
Model:
public function select(){
$this->db->select('*');
$this->db->from('result');
$this->db->join('student', 'result.student_id=student.student_id');
return $this->db->get()->result_array();
}
Controller:
public function index(){
$data = array(
'page_title' => 'Result',
'page_name' => 'result/result',
'result'=> $this->result_model->select()
);
$this->load->view('admin/template', $data);
}
View
<?php foreach ($result as $key => $value): ?>
<tr>
<td><?php echo $value['first_name']; ?></td>
<td><?php echo $value['mark']; ?></td>
</tr>
<?php endforeach;?>
You can use Group By for display your record as one time
Add This code in your model:
Model:
<?php
Class Result_model extends CI_Model {
public function __construct() {
// Call the CI_Model constructor
parent::__construct();
}
public function select(){
$this->db->select('*');
$this->db->from('result');
$this->db->join('student', 'result.student_id=student.student_id');
$this->db->group_by('student.student_id');
return $this->db->get()->result_array();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With