Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form name="formname" action="" method="POST">
- <div id="inputa">
- <p>Dari</p> <input name="dari" class="input" size="40" type="text" id="date" size="10" required="" >
- </div>
- <div id="inputa">
- <p>Sampai </p> <input type="text" name="sampai" class="input" id="datepicker" size="40">
- </div>
- <input type="submit" name="cari" id="submit" Value="Submit">
- </form>
- <?php
- extract($_POST);
- include ("../config/koneksi.php");
- if(isset($_POST['cari'])){
- $dari = date("Y-m-d", strtotime($_POST['dari']));
- $sampai = date("Y-m-d", strtotime($_POST['sampai']));
- if (($dari != null) and ($sampai != null) )
- {
- $sql=mysql_query("SELECT * FROM `tabel_penjualan` a, tabel_pelanggan b
- WHERE a.id_pelanggan = b.id_pelanggan and a.tgl_penjualan between '$dari' and '$sampai'") or die('Error, query failed. ' . mysql_error());
- $jumlah=mysql_fetch_array(mysql_query("select sum(bayar_bersih) as total from tabel_penjualan"));
- }
- else
- {
- $sql=mysql_query("SELECT * FROM `tabel_penjualan` a, tabel_pelanggan b
- WHERE a.id_pelanggan = b.id_pelanggan") or die('Error, query failed. ' . mysql_error());
- $jumlah=mysql_fetch_array(mysql_query("select sum(bayar_bersih) as total from tabel_penjualan"));
- }
- ?>
- <!---disini mau ku buat cetak dan maukan kueri berdasarkan script search yang diatas------->
- <a href="cetak.php?id=$sql">Cetak</a>
- <table id="tabel" class="display">
- <thead>
- <tr>
- <th>Kode</th>
- <th>Tgl Penjualan</th>
- <th>Pelanggan</th>
- <th>Tgl Bayar</th>
- <th>Status</th>
- <th>Penjualan</th>
- <th><a href="cetak.php?id=$sql">Cetak</a></th>
- </tr>
- </thead>
- <?php
- include ("../config/koneksi.php");
- include ("../config/fungsi_indotgl.php");
- include ("../config/rupiah.php");
- while ($data=mysql_fetch_array($sql))
- {
- ?>
- <tr>
- <td><?php echo $data['id_penjualan']?></td>
- <td><?php echo tgl_indo ($data['tgl_penjualan']);?></td>
- <td><?php echo $data['nama_pelanggan'];?></td>
- <td><?php echo tgl_indo ($data['tgl_pembelian']);?></td>
- <td><?php echo $data['status'];?></td>
- <td><?php echo rupiah($data['total_bayar']);?></td>
- </tr>
- <?php } ?>
- <tr>
- <td>Total</td>
- <td><?php echo rupiah($jumlah['total']);?></td>
- </tr>
- <tr>
- <td>
- <?php
- //jika data tidak ditemukan
- if(mysql_num_rows($sql)==0){
- echo "<font color=red><blink>Tidak ada data yang dicari!</blink></font>";
- }
- ?>
- </td>
- </tr>
- <?php
- }else{
- unset($_POST['cari']);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment