Advertisement
GWibisono

update

Jan 6th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require('config.php');
  3. require('cek-login.php');
  4. ?>
  5. <style>
  6.     tbody > tr:nth-child(2n+1) > td, tbody > tr:nth-child(2n+1) > th {
  7.         background-color: #CCC;
  8.     }
  9.     table{
  10.  
  11.         margin: auto;
  12.         border-collapse: collapse;
  13.         box-shadow: darkgrey 3px;
  14.     }
  15.     thead tr {
  16.         background-color: #36c2ff;
  17.     }
  18. </style>
  19.  
  20. <?php
  21. if (isset($_GET['message']) && $_GET['message'] == 'success') {
  22.     echo '<h3>Berhasil meng-update data!</h3>';
  23. } elseif(isset($_GET['message']) && $_GET['message'] == 'delete') {
  24.     echo '<h3>Berhasil menghapus data!</h3>';
  25. }
  26. ?>
  27. <h3>Data Customer</h3>
  28. <table border="1" cellpadding="5" cellspacing="0">
  29.     <thead>
  30.         <tr align="center">
  31.             <td><b>No</b></td>
  32.             <td><b>Customer</b></td>
  33.             <td><b>Pelapor</b></td>
  34.             <td><b>Problem</b></td>
  35.             <td><b>Tanggal Keluhan</b></td>
  36.             <td><b>Tanggapan</b></td>
  37.             <td><b>Tanggal Tanggapan</b></td>
  38.             <td><b>Waktu</b></td>
  39.             <td><b>Status</b></td>
  40.             <td><b>Opsi</b></td>
  41.  
  42.         </tr>
  43.     </thead>
  44.     <tbody>
  45.     <?php
  46. $query = mysql_query("select customer.*, tindakan.*
  47.                      FROM customer LEFT JOIN tindakan
  48.                     ON customer.idcustomer_st=tindakan.idcustomer");
  49.     //$query = mysql_query("select * from customer");
  50. //$query = mysql_query("select customer.*, tindakan.*, DATEDIFF(tindakan.date,customer.datecustomer) selisih
  51. //FROM customer LEFT JOIN tindakan
  52. //ON customer.idcustomer_st=tindakan.idcustomer"); 
  53. $sql="select customer.*, tindakan.*, TIMESTAMPDIFF(tindakan.date,customer.datecustomer) selisih
  54. FROM customer LEFT JOIN tindakan
  55. ON customer.idcustomer_st=tindakan.idcustomer";
  56. $query = mysql_query($sql) or die('error:'.mysql_error()."<br/>".$sql );
  57.     $no = 1;
  58.     while ($data = mysql_fetch_array($query)) {
  59.     ?>
  60.         <tr>
  61.             <td><?php echo $no; ?></td>
  62.             <td><?php echo $data['customer']; ?></td>
  63.             <td><?php echo $data['pelapor']; ?></td>
  64.             <td><?php echo $data['problem']; ?></td>
  65.             <td><?php echo $data['datecustomer']; ?></td>
  66.             <td><?php if(empty($data['tindakan'])){ echo '<span style="color: #f00; ">Belum ada tanggapan</span>'; } else { echo $data['tindakan']; } ?></td>
  67.             <td><?php if(empty($data['date'])){ echo '<span style="color: #f00; ">Belum ada data</span>'; } else { echo $data['date']; } ?></td>
  68.             <td><?php echo $data['selisih']; ?></td>
  69.             <td></td>
  70.            
  71.             <td>
  72.             <a href="edittanggapan.php?id=<?php echo $data['idcustomer_st']; ?>"><img alt="edit" src="gambar/edit.png" /></a>
  73.             <a href="deletetanggapan.php?id=<?php echo $data['idcustomer_st']; ?>" onclick="return confirm('Anda yakin akan menghapus data?')"><img alt="hapus" src="gambar/hapus.png" /></a>
  74.             </td>
  75.         </tr>
  76.     <?php
  77.     $no++;
  78.     }
  79.     ?>
  80.     </tbody>
  81. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement