nDh4

excel_lagi

Jun 7th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. <?php
  2.  
  3. $filename = 'dataPelanggan';
  4.  
  5. header("Content-type: application/vnd.ms-excel");
  6. header("Content-Disposition: attachment;Filename=".$filename.".xlsx");
  7. ?>
  8.  
  9. <h1>Data Pelanggan</h1>
  10.  
  11. <p>
  12. <?php echo $_POST['HARI'] ?>
  13. </p>
  14.  
  15. <?php
  16. /*
  17. saya akan buang segala yang menurut saya belum perlu
  18. seperti html.. jadi biarlah tampilannya buruk rupa seperti
  19. wajah saya
  20. */
  21.  
  22. if($_POST)
  23. {
  24. $con = mysql_connect("localhost", "root", "root") or
  25. die("Error: " . mysql_error());
  26.  
  27.  
  28. mysql_select_db("pln2", $con);
  29. $date = $_POST['date'];
  30. //$date=date('Y-m-d',strtotime($_POST['TGL']) );
  31. //$NM=$_POST['NM'];*/
  32. $sql="SELECT a.NM, b.ID_PEL, b.NO_METER, b.DY_BR, b.GARDU, b.TIANG, b.TGL, c.C_TIM, b.HARI FROM tm_plg a, td_plg b, t_tim c where a.ID_PEL=b.ID_PEL and a.C_TIM=c.C_TIM and a.STATUS_KSR=0 and a.STATUS_MAT=0 and b.TGL like '$date%' ";
  33. //echo $query = "SELECT a.NM, b.ID_PEL, b.NO_METER, b.DY_BR, b.GARDU, b.TIANG, b.TGL, c.C_TIM FROM tm_plg a, td_plg b, t_tim c where a.ID_PEL=b.ID_PEL and a.C_TIM=c.C_TIM and a.STATUS_KSR=0 and b.TGL=$tanggal";
  34. $result = mysql_query($sql)or die(mysql_error());
  35. /*
  36. pastikan dari point ini.. tampilannya BENAR!!
  37. */
  38. ?>
  39.  
  40. <hr />
  41.  
  42. <table width="86%" class="display" id="datatables" border="1" >
  43.  
  44. <thead>
  45. <tr>
  46. <th width="118">Hari</th>
  47. <th width="118">Tanggal</th>
  48. <th width="118">TIM</th>
  49. <th width="118">Nama</th>
  50. <th width="129">Id Pelanggan</th>
  51. <th width="145">Nomor Meter</th>
  52. <th width="60">Daya</th>
  53. <th width="77">Gardu</th>
  54. <th width="77">Tiang</th>
  55. </tr>
  56. <?php
  57. while ($row = mysql_fetch_array($result)) {
  58. ?>
  59. <tr>
  60. <td><? echo $row['HARI']; ?></td>
  61. <td><? echo $row['TGL']; ?></td>
  62. <td><? echo $row['C_TIM']; ?></td>
  63. <td><? echo $row['NM']; ?></td>
  64. <td>trim() <? echo $row['ID_PEL']; ?></td>
  65. <td><? echo $row['NO_METER']; ?></td>
  66. <td><? echo $row['DY_BR']; ?></td>
  67. <td><? echo $row['GARDU']; ?></td>
  68. <td><? echo $row['TIANG']; ?></td>
  69. </tr>
  70. <?php
  71. }}
  72. ?>
  73. </thead>
  74. </table>
Advertisement
Add Comment
Please, Sign In to add comment