freddy0512

search

Nov 24th, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. <form name="formname" action="" method="POST">
  2. <div id="inputa">
  3. <p>Dari</p> <input name="dari" class="input" size="40" type="text" id="date" size="10" required="" >
  4. </div>
  5.  
  6.  
  7. <div id="inputa">
  8. <p>Sampai </p> <input type="text" name="sampai" class="input" id="datepicker" size="40">
  9. </div>
  10. <input type="submit" name="cari" id="submit" Value="Submit">
  11. </form>
  12.  
  13. <?php
  14. extract($_POST);
  15. include ("../config/koneksi.php");
  16. if(isset($_POST['cari'])){
  17.  
  18. $dari = date("Y-m-d", strtotime($_POST['dari']));
  19. $sampai = date("Y-m-d", strtotime($_POST['sampai']));
  20.  
  21.  
  22. if (($dari != null) and ($sampai != null) )
  23. {
  24. $sql=mysql_query("SELECT * FROM `tabel_penjualan` a, tabel_pelanggan b
  25. WHERE a.id_pelanggan = b.id_pelanggan and a.tgl_penjualan between '$dari' and '$sampai'") or die('Error, query failed. ' . mysql_error());
  26. $jumlah=mysql_fetch_array(mysql_query("select sum(bayar_bersih) as total from tabel_penjualan"));
  27. }
  28. else
  29. {
  30. $sql=mysql_query("SELECT * FROM `tabel_penjualan` a, tabel_pelanggan b
  31. WHERE a.id_pelanggan = b.id_pelanggan") or die('Error, query failed. ' . mysql_error());
  32. $jumlah=mysql_fetch_array(mysql_query("select sum(bayar_bersih) as total from tabel_penjualan"));
  33.  
  34. }
  35. ?>
  36.  
  37. <!---disini mau ku buat cetak dan maukan kueri berdasarkan script search yang diatas------->
  38. <a href="cetak.php?id=$sql">Cetak</a>
  39.  
  40.  
  41.  
  42. <table id="tabel" class="display">
  43. <thead>
  44. <tr>
  45. <th>Kode</th>
  46. <th>Tgl Penjualan</th>
  47. <th>Pelanggan</th>
  48. <th>Tgl Bayar</th>
  49. <th>Status</th>
  50. <th>Penjualan</th>
  51. <th><a href="cetak.php?id=$sql">Cetak</a></th>
  52. </tr>
  53. </thead>
  54. <?php
  55. include ("../config/koneksi.php");
  56. include ("../config/fungsi_indotgl.php");
  57. include ("../config/rupiah.php");
  58. while ($data=mysql_fetch_array($sql))
  59. {
  60. ?>
  61. <tr>
  62. <td><?php echo $data['id_penjualan']?></td>
  63. <td><?php echo tgl_indo ($data['tgl_penjualan']);?></td>
  64. <td><?php echo $data['nama_pelanggan'];?></td>
  65. <td><?php echo tgl_indo ($data['tgl_pembelian']);?></td>
  66. <td><?php echo $data['status'];?></td>
  67.  
  68. <td><?php echo rupiah($data['total_bayar']);?></td>
  69.  
  70. </tr>
  71. <?php } ?>
  72.  
  73. <tr>
  74. <td>Total</td>
  75. <td><?php echo rupiah($jumlah['total']);?></td>
  76. </tr>
  77.  
  78.  
  79. <tr>
  80. <td>
  81. <?php
  82. //jika data tidak ditemukan
  83. if(mysql_num_rows($sql)==0){
  84. echo "<font color=red><blink>Tidak ada data yang dicari!</blink></font>";
  85. }
  86. ?>
  87. </td>
  88. </tr>
  89.  
  90. <?php
  91. }else{
  92. unset($_POST['cari']);
  93. }
  94. ?>
Advertisement
Add Comment
Please, Sign In to add comment