Membuat search Engine dari 2 tabel yg dimerge

saya sedang membuat serach engine untuk data yang bersumber dari 2 tabel. kedua tabel merupakan hasil inputan dari penjualan. tabel 1 adalah tabel yang berisikan informasi umum berisi kode penjualan dan nama pelanggan, tabel 2 berisi detail barang yang dibeli pelanggan. apabila jumlah barang yang dibeli pelanggan lebih dari 2, maka tabel akan menampilkan hasil merge untuk tabel 1. yang ingin ditanyakan, bagaimana saya bisa membuat search engine utk data tersebut ya?misal saya ketikan nama barangnya yg dibeli, maka otomatis akan muncul seluruh datanya. terimakasih


            <table class="table table-head-fixed text-nowrap" style="font-size: 12px;">
              <thead>
                <tr>
                    <th>NO</th>		
                    <th>FCS ID</th>				
                    <th>DATE</th>		
                    <th>ACTION</th>	
                    <th>TYPE</th>
                    <th>ACC. CODE</th>
                    <th>ACC. NAME</th>
                    <th>NOMINAL</th>
                    <th>REFF NO.</th>
                    <th>NOTE'S</th>
                </tr>
              </thead> 
                  <?php
                    include "../../koneksi.php";
                    if (isset($_POST['kata_kunci'])) {
                        $kata_kunci=trim($_POST['kata_kunci']);
                        $sql="SELECT * FROM fcs_new, fcs_detail WHERE fcs_new.kode = fcs_detail.kode and fcs_detail.account_name like '%".$kata_kunci."%'  order by fcs_new.kode desc";
                    }else {
                        $sql="SELECT * FROM fcs_new, fcs_detail WHERE fcs_new.kode = fcs_detail.kode order by fcs_new.kode desc ";
                    }
                    $hasil=mysqli_query($koneksi,$sql);
                    $no=1;
                    $arr = array();
                    while ($row  = mysqli_fetch_object($hasil)) {
                        $arr[$row->kode][] = $row;
                    }
                    ?>
 
              <tbody>
                <?php foreach ($arr as $key => $val) : ?>
                <?php foreach ($val as $k => $v) : ?>
                 
                <tr>
                    <?php if ($k == 0) : ?>
                        <td rowspan="<?php echo count($val) ?>">
                            <?php echo $no++ ?>
                        </td>
                        <td rowspan="<?php echo count($val) ?>">
                            <?php echo $v->kode ?>
                        </td>
                        <td rowspan="<?php echo count($val) ?>">
                            <?php echo date('d-M-y', strtotime($v->date)); ?>
                        </td>
                    <?php endif ?>
                        <td>
                            <div class="btn-group" role="group" aria-label="Basic outlined example"> 
                                <button type="button" style="font-size: 8px;" class="btn btn-outline-primary btn-sm" data-toggle="modal" data-target="#edit<?php echo $v->nomor  ?>" title="Klik untuk edit transaksi"><span class="fa fa-edit"></span></button>
                            </div>
                        </td>
                        <td><?php echo $v->type ?></td>
                        <td><?php echo $v->account ?></td>
                        <td><?php echo $v->account_name ?></td>
                        <td>Rp <?php echo number_format($v->nominal,3,",", "."); ?></td>                        
                    <?php if ($k == 0) : ?>
                        <td rowspan="<?php echo count($val) ?>">
                            <?php echo $v->reff ?>
                        </td>
                        <td rowspan="<?php echo count($val) ?>">
                            <?php echo $v->note ?>
                        </td>
                    <?php endif ?>                    
                </tr>
            <?php endforeach ?>
        <?php endforeach ?>
              </tbody>
              </tfoot>
            </table>
avatar enthrall
@enthrall

9 Kontribusi 2 Poin

Diperbarui 9 bulan yang lalu

1 Jawaban:

kamu bisa melakukan JOIN table untuk menggabungkan 2 table atau lebih refrensi join table

Kami tidak tahu struktur database kamu seperti apa, tapi selama ada data yang menghubungkan kedua table tersebut, kamu bisa pakai JOIN

avatar hilmanski
@hilmanski

2672 Kontribusi 2132 Poin

Dipost 9 bulan yang lalu

Login untuk ikut Jawaban