Home » Php » mysql – Showing related data using php

mysql – Showing related data using php

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am currently working on the web-based mail application project.

How this application works with when changing data will not change anything on the old data, but old data will be connected to new data.

So that when the old data appears there will still be and associated with new data.

Basically when there is a new file associated with the old file, then the new file will be c child of the old file.

but until now I have not been able to display new data with conditions related to old data

I give a picture of my project,

Source Code (CONTROLLER)

public function cari2($id)
{
    $data['user'] = $this->db->get_where('user', ['username' => $this->session->userdata('username')])->row_array();
    $data['judul'] = 'Cari Data';
    $data['bul2'] = $this->bulog_m->getId($id);
   $data['bul'] = $this->bulog_m->getAll2()->result_array();
   //$data['bul'] = $this->db->query("SELECT * FROM detail_pdf a join filepdf b on b.id=a.idpdf join filepdf1 c on c.id1=a.idpdf1 where a.idpdf = '$id'")->result_array();
    $data['bul1'] = $this->bulog_m->getAll()->result_array();
    //  $data['bul1'] = $this->bulog_m->getAll1()->result_array();
    // $data['bul'] = $this->bulog_m->getAll2()->result_array();






    if ($this->input->post('keyword')) {
        $data['bul'] = $this->bulog_m->cariDataBerobat();
        $data['bul1'] = $this->bulog_m->cariDataBerobat1();
    }

    $this->load->view('templates/header', $data);
    $this->load->view('templates/sidebar2', $data);
    $this->load->view('bulog/cari2', $data);
    $this->load->view('templates/footer');
}

Source Code (MODEL)

public function getAll()
{

    return $this->db->get('filepdf');
}
public function getAll2()
{
    $this->db->select('*');
    $this->db->from('detail_pdf');
    $this->db->join('filepdf', 'filepdf.id=detail_pdf.idpdf');
    $this->db->join('filepdf1', 'filepdf1.id1=detail_pdf.idpdf1');

    return $this->db->get();
}

Source Code (VIEW)

<div class="col-md-8 konten">
<div class="table-responsive">  <table class="table table-bordered" bgcolor=#605e5e>
    <tr><td>KEPUTUSAN DIREKSI TELAH MENGALAMI PERUBAHAN/PENCABUTAN</tr></td>
</table></div>
        <div class="table-responsive">
        <?php foreach ($bul as $b) : ?>
                <table class="table table-bordered">
                <tr>
                        <td>

                            K.D No: <?= $b['kode']; ?> Tahun : <?php $tgl = $b['tgl'];
                                                                    echo date('Y', strtotime($tgl));
                                                                    ?>
                            telah <?= $b['status']; ?> oleh <?= $b['kode1']; ?></td>
                    <tr>
                        <td> <a href="<?= base_url(); ?>bulog/cari3/<?= $b['id']; ?>"><?= $b['nama']; ?> </a></td>



                    </tr>

                    <tr class="">
                        <td class="">
                            <a href="<?= base_url() . 'bulog/download/' . $b['id']; ?>" class="small">Download</a>
                        </td>
                    </tr>
                </table>
                <?php endforeach; ?>
            </div>
        </div>
How to&Answers: