Reputation: 25
I am nubie in Codeigniter. to the point. I have query in my controller
My Controller
$result_criteria = $this->app_model->manualQuery("select b.nik,b.hubkel
from biodata_karyawan bk left join bpjs b
on b.nik = bk.nik where bk.status_karyawan = 'Aktif' and " . $bagianWhere ." order by b.nik");
$bc['dt_karyawan'] = $this->db->query("$result_criteria");
then it's my view where my foreach in foreach because I want selected by category of b.hubkel like this
My View
foreach($dt_karyawan->result() as $row)
{
if($row->hubkel=='pegawai')
{
$query_pegawai = "select bk.no_kk as 'no_2' ....";
foreach($query_pegawai->result() as $data1)
{
echo '<tr align="center">';
echo '<td>'.$no.'</td>';
echo '<td>'.$kutip.$data1->no_2.'</td>';
.
.
}
}
if($row->hubkel=='istri')
{
.
.
.
}
}
what wrong with my code guy? I have searching but not understand with this. thanks for your time
Upvotes: 1
Views: 1048
Reputation: 648
change in controller
$result_criteria = $this->app_model->manualQuery("select b.nik,b.hubkel
from biodata_karyawan bk left join bpjs b
on b.nik = bk.nik where bk.status_karyawan = 'Aktif' and " . $bagianWhere ." order by b.nik");
$bc['dt_karyawan'] = $this->db->query($result_criteria)->result();
change in views as following
foreach($dt_karyawan as $row)
{
if($row->hubkel=='pegawai')
{
$query_pegawai = "select bk.no_kk as 'no_2' ....";
foreach($query_pegawai->result() as $data1)
{
echo '<tr align="center">';
echo '<td>'.$no.'</td>';
echo '<td>'.$kutip.$data1->no_2.'</td>';
.
.
}
}
if($row->hubkel=='istri')
{
.
.
.
}
}
Upvotes: 1