Advertisement
SuperBag

fetch.php

Mar 12th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <?php
  2. include "../../config/koneksi.php";
  3. include "../../function/function.php";
  4.  
  5. $query="select*from beli";
  6. $statement=$dbh->prepare($query);
  7. $statement->execute();
  8. $result=$statement->fetchAll();
  9. $total_row=$statement->rowCount();
  10. $output = '
  11.    <table class="table table-striped table-bordered">
  12.        <tr>
  13.            <th>Kode Transaksi</th>
  14.            <th>Tanggal</th>
  15.            <th>Nama Supplier</th>
  16.            <th>Keterangan</th>
  17.            <th>Total</th>
  18.            <th>Bayar</th>
  19.            <th>Edit</th>
  20.            <th>Delete</th>
  21.        </tr>
  22. ';
  23. if($total_row>0){
  24.     foreach($result as $row){
  25.         $carinama="select*from supplier where idsupp='".$row['idsupp']."'";
  26.         $nama=$dbh->prepare($carinama);
  27.         $nama->execute();
  28.         $tampil=$nama->fetchAll();
  29.         foreach($tampil as $hasil){
  30.             $namasupp=$hasil['namasupp'];
  31.         }
  32.         $output .= '
  33.            <tr>
  34.                <td width="40%">'.$row["kdtransaksi"].'</td>
  35.                <td width="40%">'.tanggalIndo($row["tanggal"]).'</td>
  36.                <td width="40%">'.$namasupp.'</td>
  37.                <td width="40%">'.$row["keterangan"]." dari ".$namasupp.'</td>
  38.                <td width="40%">'.$row["total"].'</td>
  39.                <td width="40%">'.$row["bayar"].'</td>
  40.                <td width="10%"><button type="button" name="edit" class="btn btn-primary btn-xs edit" id="'.$row["idbeli"].'">Edit</button></td>
  41.                <td width="10%"><button type="button" name="delete" class="btn btn-danger btn-xs delete" id="'.$row["idbeli"].'">Delete</button></td>
  42.            </tr>
  43.        ';
  44.     }
  45. }else{
  46.     $output.='
  47.        <tr>
  48.            <td colspan="8" align="center">Data tidak ditemukan</td>
  49.        </tr>
  50.    ';
  51. }
  52. $output.='</table>';
  53. echo $output;
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement