Advertisement
GWibisono

excel lagi

Jun 7th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.14 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.".xls");
  7. ?>
  8.  
  9. <h1>Data Pelanggan</h1>
  10.  
  11. <p>
  12.   <?php echo $_POST['HARI'] ?>
  13. </p>
  14.  
  15. <?php
  16.  
  17.     if($_POST)
  18.     {
  19.             $con = mysql_connect("localhost", "root", "root") or
  20.                     die("Error: " . mysql_error());
  21.             mysql_select_db("pln2", $con);
  22.             $date = $_POST['date'];
  23.             $sql="SELECT
  24. a.NM, b.ID_PEL, b.NO_METER, b.DY_BR, b.GARDU,
  25. b.TIANG, b.TGL, c.C_TIM, b.HARI
  26.     FROM
  27. tm_plg a, td_plg b, t_tim c
  28.     where
  29. a.ID_PEL=b.ID_PEL and
  30. a.C_TIM=c.C_TIM and
  31. a.STATUS_KSR=0 and
  32. a.STATUS_MAT=0 and
  33. b.TGL like '$date%' ";
  34.              
  35.             $result = mysql_query($sql)or die(mysql_error());
  36.             /*
  37.             pastikan dari point ini.. tampilannya BENAR!!
  38.             */
  39.     ?>  
  40.     <hr />
  41. <table width="86%" class="display" id="datatables" border="1" >
  42.   <thead>
  43.         <tr>
  44.             <th width="118">Hari</th>        
  45.             <th width="118">Tanggal</th>            
  46.             <th width="118">TIM</th>            
  47.             <th width="118">Nama</th>
  48.             <th width="129">Id Pelanggan</th>
  49.             <th width="145">Nomor Meter</th>
  50.             <th width="60">Daya</th>
  51.             <th width="77">Gardu</th>
  52.             <th width="77">Tiang</th>
  53.         </tr>
  54.                   <?php
  55.                         while ($row = mysql_fetch_array($result)) {
  56.                             ?>
  57.         <tr>
  58.             <td><? echo trim($row['HARI']); ?></td>
  59.             <td><? echo trim($row['TGL']); ?></td>
  60.             <td><? echo trim($row['C_TIM']); ?></td>        
  61.             <td><? echo trim($row['NM']); ?></td>
  62.             <td>trim() <? echo trim($row['ID_PEL']); ?></td>
  63.             <td><? echo trim($row['NO_METER']); ?></td>
  64.             <td><? echo trim($row['DY_BR']); ?></td>
  65.             <td><? echo trim($row['GARDU']); ?></td>
  66.             <td><? echo trim($row['TIANG']); ?></td>
  67.         </tr>
  68.         <?php
  69.                         } ?>
  70.     </thead>
  71. </table>
  72. <?php
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement