1
  1. image of my database table 3 tables
  2. this is the layout from my web.data in table 'pembayaran_infaq' is only 1 row but this is duplicate duploicate
  3. data from table 'pembayaran_spp' and 'pembayaran_infaq' in database data from database

im already try but the data from 'pembayaran_infaq' is duplicate. i want to show 'pembayaran_spp' and 'pembayaran_infaq' using $id_siswa. thank you

my_model

function riwayatbayarsiswa($id_siswa)
    {
        $this->db->select('*');
        $this->db->from('siswa a');
        $this->db->join('pembayaran_spp b','b.id_siswa=a.id_siswa','left');
        $this->db->join('pembayaran_infaq c', 'c.id_siswa=a.id_siswa','left');
        $this->db->where('a.id_siswa',$id_siswa);
        //$this->db->distinct();
        return $this->db->get();
    }

my controller

function riwayatbayar($id_siswa)
    {
        $data['siswa'] = $this->M_keuangan->riwayatbayarsiswa($id_siswa)->result();
        $this->load->view('template/header');
        $this->load->view('template/sidebar');
        $this->load->view('keuangan/v_detailtagihan',$data);
        //$this->load->view('template/footer');
    }
Community
  • 1
  • 1
  • @pradeep it doesnt work sir. – Catur Ananta Putra Jul 04 '18 at 07:32
  • it doesnt work "Undefined property: stdClass::$nama_siswa". it is in my view. the data from the tables is duplicate too.i have 2 row data in table 'pembayaran_spp' and 1 row in table 'pembayaran_infaq'. its show 2 and 2 in the view. its duplicate from 'pembayaran_infaq' – Catur Ananta Putra Jul 04 '18 at 07:37
  • without seeing your table data unable to help u but for now try with `inner join` instead of `left join` – Pradeep Jul 04 '18 at 07:44
  • the data from the table is show correctly. 2 row in 'pembayaran_spp'. but the data in table 'pembayaran_infaq' is duplicate show. should i put the view code too? – Catur Ananta Putra Jul 04 '18 at 07:54

0 Answers0