1

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

1
  • I would investigate the magic of print_r, var_export, or var_dump. Commented Jul 24, 2015 at 3:17

1 Answer 1

1

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')
 { 
 .
 .
 .
 }
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.