Advertisement
Guest User

tampil record kosong

a guest
Mar 3rd, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. <?php
  2. include_once('koneksi.php');
  3. $query=mysql_query("select * from data order by tgl") or die ("Query error");
  4. ?>
  5. <table border="1">
  6.     <tr>
  7.         <th>No.</th>
  8.         <th>Tanggal</th>
  9.         <th>Nama</th>
  10.         <th>Jumlah</th>
  11.     </tr>
  12. <?php
  13. $no=1;
  14. while($data=mysql_fetch_array($query)){
  15.     $ts1 = strtotime($dtBefore);
  16.     $ts2 = strtotime($data[tgl]);
  17.    
  18.     $seconds_diff = $ts2 - $ts1;
  19.     $dtdiff = floor($seconds_diff/3600/24);
  20.    
  21.     if($no > 1 && $dtdiff > 1){
  22.         for($x = 1;$x < $dtdiff;$x ++){
  23.             $dtTemp = date('Y-m-d', strtotime("+$x days", strtotime($dtBefore)));
  24.             echo"
  25.                 <tr>
  26.                     <td>$no</td>
  27.                     <td>$dtTemp</td>
  28.                     <td></td>
  29.                     <td></td>
  30.                 </tr>  
  31.             ";
  32.             $no++;
  33.         }
  34.     }
  35.    
  36.    
  37. ?>
  38.     <tr>
  39.         <td><?php echo $no++; ?></td>
  40.         <td><?php echo $data['tgl']; ?></td>
  41.         <td><?php echo $data['nama']; ?></td>
  42.         <td><?php echo $data['jumlah']; ?></td>
  43.     </tr>
  44. <?php
  45.     $dtBefore   = $data['tgl'];
  46. }
  47. ?>
  48. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement