CI-Menjumlahkan Tabel
Menjumlahkan nilai Tabel
View
<td>Total</td>
<?php $sum=0; foreach ($total_biaya as $total):?>
<?php echo $total->nilai?>
<?php endforeach;?>
Model
class Radmlaporan extends CI_Model{
public function get_total_biaya()
{
return $this->db->query("SELECT sum(nilai) as nilai,nama FROM tb_nilai");
}
}
atau juga bisa menggunakan
return $this->db->select('sum(nilai) as nilai')->from('tb_nilai')
->get();
Atau
return $this->db->select('sum(nilai) as nilai')
->get('tb_nilai');
Controller
$data['total_biaya']=$this->radmlaporan->get_total_biaya()->result();
$this->load->view('welcome_message',$data);
View
<td>Total</td>
<?php $sum=0; foreach ($total_biaya as $total):?>
<?php echo $total->nilai?>
<?php endforeach;?>
Model
class Radmlaporan extends CI_Model{
public function get_total_biaya()
{
return $this->db->query("SELECT sum(nilai) as nilai,nama FROM tb_nilai");
}
}
atau juga bisa menggunakan
return $this->db->select('sum(nilai) as nilai')->from('tb_nilai')
->get();
Atau
return $this->db->select('sum(nilai) as nilai')
->get('tb_nilai');
Controller
$data['total_biaya']=$this->radmlaporan->get_total_biaya()->result();
$this->load->view('welcome_message',$data);
CI-Menjumlahkan Tabel
Reviewed by Leo
on
19:54
Rating:
No comments