Cara Membuat Filter Bulan

bagaimana cara membuat filter yang menampilkan berdasarkan bulan?

berikut screenshot

Filter Bulan

berikut screenshot database

Database

berikut codenya

<?php if ($_GET[act]==''){ ?>
            <div class="col-xs-12">
              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">Buku Kas Umum</h3>
                  <?php if($_SESSION[level]!='kepala'){ ?>
                  <a class='pull-right btn btn-primary btn-sm' href='index.php?view=kasumum&act=tambah'>Tambahkan Data</a>
                  <?php } ?>

                  <form method='POST' action='' style='margin-right:5px; margin-top:0px' class='pull-right'>
                  <div class="form-group">
                    <select name='bulan' style='padding:4px'>
                            <option value="">- Filter Bulan -</option>
                            <option value="01">Januari</option>
                            <option value="02">Februari</option>
                            <option value="03">Maret</option>
                            <option value="04">April</option>
                            <option value="05">Mei</option>
                            <option value="06">Juni</option>
                            <option value="07">Juli</option>
                            <option value="08">Agustus</option>
                            <option value="09">September</option>
                            <option value="10">Oktober</option>
                            <option value="11">November</option>
                            <option value="12">Desember</option>
                    </select>
                    <button id="search" name="search" style='margin-top:-4px' class="btn btn-info btn-sm">Lihat</button>
                  </div>
                  </form>

                </div><!-- /.box-header -->
                <div class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th style="width:10px; text-align: center;" rowspan="2">No</th>
                        <th style="text-align: center;" rowspan="2">Tanggal</th>
                        <th style="text-align: center;" colspan="3">Nomor</th>
                        <th style="text-align: center;" rowspan="2">Keterangan</th>
                        <th style="text-align: center;" rowspan="2">Penerimaan</th>
                        <th style="text-align: center;" rowspan="2">Pengeluaran</th>
                        <th style="width: 75px; text-align: center;" rowspan="2">Saldo</th>
                        <?php if($_SESSION[level]!='kepala'){ ?>
                        <th style="width:20px; text-align: center;" rowspan="2">Action</th>
                        <?php } ?>
                      </tr>
                      <tr>
                        <th style="text-align: center;">Kode</th>
                        <th style="text-align: center;">Bukti</th>
                        <th style="text-align: center;">Rek Belanja</th>
                      </tr>
                    </thead>
                    <tbody>
                  <?php
                    $tampil = mysql_query("SELECT * FROM rb_buku_kas_umum ORDER BY kode_bku ASC");
                    $no = 1;
                    $saldo = 0;
                    while($r=mysql_fetch_array($tampil)){
                    $saldo = $saldo + $r[debit];
                    $saldo = $saldo - $r[credit];
                    $debit = $debit + $r[debit];
                    $credit = $credit + $r[credit];
                    echo "<tr>
                              <td>$no</td>
                              <td>$r[tgl]</td>
                              <td>$r[kode_k7]</td>
                              <td>$r[bukti]</td>
                              <td>$r[rek_blj]</td>
                              <td>$r[keterangan]</td>
                              <td>Rp. ".number_format($r[debit])."</td>
                              <td>Rp. ".number_format($r[credit])."</td>
                              <td>Rp. ".number_format($saldo)."</td>";
                              if($_SESSION[level]!='kepala'){
                        echo "<td><center>
                                <a class='btn btn-success btn-xs' title='Edit Data' href='index.php?view=kasumum&act=edit&id=$r[kode_bku]'><span class='glyphicon glyphicon-edit'></span></a>
                                <a class='btn btn-danger btn-xs' title='Delete Data' href='index.php?view=kasumum&hapus=$r[kode_bku]'><span class='glyphicon glyphicon-remove'></span></a>
                              </center></td>";
                              }
                            echo "</tr>";
                      $no++;
                      }
                      if (isset($_GET[hapus])){
                          mysql_query("DELETE FROM rb_buku_kas_umum where kode_bku='$_GET[hapus]'");
                          echo "<script>document.location='index.php?view=kasumum';</script>";
                      }

                  ?>
                    </tbody>
                    <tfoot>
                    <tr>
                      <td colspan='6' style='text-align:right;'>Total</td>
                      <td>Rp. <?php echo number_format($debit); ?></td>
                      <td>Rp. <?php echo number_format($credit); ?></td>
                      <td colspan="2">Rp. <?php echo number_format($saldo); ?></td>
                    </tr>
                  </tfoot>
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div>
<?php
}elseif($_GET[act]=='edit'){
    if (isset($_POST[update])){
        mysql_query("UPDATE rb_buku_kas_umum SET
                                        tgl = '$_POST[a]',
                                        kode_k7 = '$_POST[b]',
                                        bukti = '$_POST[c]',
                                        rek_blj = '$_POST[d]',
                                        keterangan = '$_POST[e]',
                                        debit = '$_POST[f]',
                                        credit = '$_POST[g]' where kode_bku='$_GET[id]'");
      echo "<script>document.location='index.php?view=kasumum';</script>";
    }
    $edit = mysql_query("SELECT * FROM rb_buku_kas_umum where kode_bku='$_GET[id]'");
    $s = mysql_fetch_array($edit);
    echo "<div class='col-md-12'>
              <div class='box box-info'>
                <div class='box-header with-border'>
                  <h3 class='box-title'>Edit Data Buku Kas Umum</h3>
                </div>
              <div class='box-body'>
              <form method='POST' class='form-horizontal' action='' enctype='multipart/form-data'>
                <div class='col-md-6'>
                  <table class='table table-condensed table-bordered'>
                  <tbody>
                    <tr><th width='120px' scope='row'>Tanggal</th> <td><input type='date' class='form-control' name='a' value='$s[tgl]'> </td></tr>
                    <tr><th scope='row'>Kode K7</th> <td><select class='form-control' name='b'>
                                                                            <option value='' selected>- Pilih Kode K7 -</option>";
                                                                              $kodek7 = mysql_query("SELECT * FROM rb_kode_k7");
                                                                              while($b = mysql_fetch_array($kodek7)){
                                                                                  echo "<option value='$b[kode_kegiatan]'>$b[kode_kegiatan] $b[keterangan]</option>";
                                                                              }
                                                                    echo "</select></td></tr>

                    <tr><th width='120px' scope='row'>Bukti</th> <td><input type='text' class='form-control' name='c' value='$s[bukti]'> </td></tr>
                    <tr><th scope='row'>Rekening Belanja</th> <td><select class='form-control' name='d'>
                                                                            <option value='' selected>- Pilih Rek. Belanja -</option>";
                                                                              $koderek = mysql_query("SELECT * FROM rb_rek_belanja");
                                                                              while($d = mysql_fetch_array($koderek)){
                                                                                  echo "<option value='$d[kode_blj]'>$d[kode_blj] $d[keterangan]</option>";
                                                                              }
                                                                    echo "</select></td></tr>

                    <tr><th width='120px' scope='row'>Keterangan</th> <td><input type='text' class='form-control' name='e' value='$s[keterangan]'> </td></tr>
                    <tr><th width='120px' scope='row'>Penerimaan</th> <td><input type='number' class='form-control' name='f' value='$s[debit]'> </td></tr>
                    <tr><th width='120px' scope='row'>Pengeluaran</th> <td><input type='number' class='form-control' name='g' value='$s[credit]'> </td></tr>
                    </tbody>
                  </table>
                </div>
              </div>
              <div class='box-footer'>
                    <button type='submit' name='update' class='btn btn-info'>Update</button>
                    <a href='index.php?view=kasumum'><button type='button' class='btn btn-default pull-right'>Cancel</button></a>

                  </div>
              </form>
            </div>";
}elseif($_GET[act]=='tambah'){
    if (isset($_POST[tambah])){
        mysql_query("INSERT INTO rb_buku_kas_umum VALUES('','$_POST[a]','$_POST[b]','$_POST[c]','$_POST[d]','$_POST[e]','$_POST[f]','$_POST[g]')");
        echo "<script>document.location='index.php?view=kasumum';</script>";
    }

    echo "<div class='col-md-12'>
              <div class='box box-info'>
                <div class='box-header with-border'>
                  <h3 class='box-title'>Tambah Data Buku Kas Umum</h3>
                </div>
              <div class='box-body'>
              <form method='POST' class='form-horizontal' action='' enctype='multipart/form-data'>
                <div class='col-md-6'>
                  <table class='table table-condensed table-bordered'>
                  <tbody>
                    <tr><th width='120px' scope='row'>Tanggal</th> <td><input type='date' class='form-control' name='a'> </td></tr>
                    <tr><th scope='row'>Kode K7</th> <td><select class='form-control' name='b'>
                                                                            <option value='' selected>- Pilih Kode K7 -</option>";
                                                                              $kodek7 = mysql_query("SELECT * FROM rb_kode_k7");
                                                                              while($b = mysql_fetch_array($kodek7)){
                                                                                  echo "<option value='$b[kode_kegiatan]'>$b[kode_kegiatan] $b[keterangan]</option>";
                                                                              }
                                                                    echo "</select></td></tr>

                    <tr><th width='120px' scope='row'>Bukti</th> <td><input type='text' class='form-control' name='c'> </td></tr>
                    <tr><th scope='row'>Rekening Belanja</th> <td><select class='form-control' name='d'>
                                                                            <option value='' selected>- Pilih Rek. Belanja -</option>";
                                                                              $koderek = mysql_query("SELECT * FROM rb_rek_belanja");
                                                                              while($d = mysql_fetch_array($koderek)){
                                                                                  echo "<option value='$d[kode_blj]'>$d[kode_blj] $d[keterangan]</option>";
                                                                              }
                                                                    echo "</select></td></tr>

                    <tr><th width='120px' scope='row'>Keterangan</th> <td><input type='text' class='form-control' name='e'> </td></tr>
                    <tr><th width='120px' scope='row'>Penerimaan</th> <td><input type='number' class='form-control' name='f'> </td></tr>
                    <tr><th width='120px' scope='row'>Pengeluaran</th> <td><input type='number' class='form-control' name='g'> </td></tr>
                  </tbody>
                  </table>
                </div>
              </div>
              <div class='box-footer'>
                    <button type='submit' name='tambah' class='btn btn-info'>Tambahkan</button>
                    <a href='index.php?view=kasumum'><button type='button' class='btn btn-default pull-right'>Cancel</button></a>

                  </div>
              </form>
            </div>";
}
?>

mungkin ada yang tahu caranya? karna saya sudah coba dari beberapa artikel di google blm ada yg work.

avatar hikamauthar
@hikamauthar

6 Kontribusi 0 Poin

Diperbarui 3 tahun yang lalu

1 Jawaban:

<div>Cek jawaban jawabn di forum ini<br><br><a href="https://sekolahkoding.com/forum/filter-data-berdasarkan-idnama-bulan-dan-tahun-mysql-php-1571304137">https://sekolahkoding.com/forum/filter-data-berdasarkan-idnama-bulan-dan-tahun-mysql-php-1571304137</a><br><br><a href="https://sekolahkoding.com/forum/bagaimana-ara-filter-data">https://sekolahkoding.com/forum/bagaimana-ara-filter-data</a><br><br><a href="https://sekolahkoding.com/forum/bagaimana-cara-filter-database-dengan-php-cara-lain-1539770639">https://sekolahkoding.com/forum/bagaimana-cara-filter-database-dengan-php-cara-lain-1539770639</a></div>

avatar hilmanski
@hilmanski

2686 Kontribusi 2135 Poin

Dipost 3 tahun yang lalu

Login untuk ikut Jawaban