nebukad

Listing Komentar

Feb 21st, 2015
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.38 KB | None | 0 0
  1. <style>
  2.     /*
  3. table a:link {
  4.     color: #666;
  5.     font-weight: bold;
  6.     text-decoration:none;
  7. }
  8. table a:visited {
  9.     color: #999999;
  10.     font-weight:bold;
  11.     text-decoration:none;
  12. }
  13. table a:active,
  14. table a:hover {
  15.     color: #bd5a35;
  16.     text-decoration:underline;
  17. }
  18.     */
  19. table {
  20.     font-family:Arial, Helvetica, sans-serif;
  21.     color:#666;
  22.     font-size:12px;
  23.     text-shadow: 1px 1px 0px #fff;
  24.     background:#eaebec;
  25.     margin:20px;
  26.     border:#ccc 1px solid;
  27.     width: 100%;
  28.  
  29.     -moz-border-radius:3px;
  30.     -webkit-border-radius:3px;
  31.     border-radius:3px;
  32.  
  33.     -moz-box-shadow: 0 1px 2px #d1d1d1;
  34.     -webkit-box-shadow: 0 1px 2px #d1d1d1;
  35.     box-shadow: 0 1px 2px #d1d1d1;
  36. }
  37. table th {
  38.     padding:21px 25px 22px 25px;
  39.     border-top:1px solid #fafafa;
  40.     border-bottom:1px solid #e0e0e0;
  41.  
  42.     background: #ededed;
  43.     background: -webkit-gradient(linear, left top, left bottom, from(#ededed), to(#ebebeb));
  44.     background: -moz-linear-gradient(top,  #ededed,  #ebebeb);
  45. }
  46. table th:first-child {
  47.     text-align: left;
  48.     padding-left:20px;
  49. }
  50. table tr:first-child th:first-child {
  51.     -moz-border-radius-topleft:3px;
  52.     -webkit-border-top-left-radius:3px;
  53.     border-top-left-radius:3px;
  54. }
  55. table tr:first-child th:last-child {
  56.     -moz-border-radius-topright:3px;
  57.     -webkit-border-top-right-radius:3px;
  58.     border-top-right-radius:3px;
  59. }
  60. table tr {
  61.     text-align: center;
  62.     padding-left:20px;
  63. }
  64. table td:first-child {
  65.     text-align: left;
  66.     padding-left:20px;
  67.     border-left: 0;
  68. }
  69. table td {
  70.     padding:18px;
  71.     border-top: 1px solid #ffffff;
  72.     border-bottom:1px solid #e0e0e0;
  73.     border-left: 1px solid #e0e0e0;
  74.  
  75.     background: #fafafa;
  76.     background: -webkit-gradient(linear, left top, left bottom, from(#fbfbfb), to(#fafafa));
  77.     background: -moz-linear-gradient(top,  #fbfbfb,  #fafafa);
  78. }
  79. table tr.even td {
  80.     background: #f6f6f6;
  81.     background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#f6f6f6));
  82.     background: -moz-linear-gradient(top,  #f8f8f8,  #f6f6f6);
  83. }
  84. table tr:last-child td {
  85.     border-bottom:0;
  86. }
  87. table tr:last-child td:first-child {
  88.     -moz-border-radius-bottomleft:3px;
  89.     -webkit-border-bottom-left-radius:3px;
  90.     border-bottom-left-radius:3px;
  91. }
  92. table tr:last-child td:last-child {
  93.     -moz-border-radius-bottomright:3px;
  94.     -webkit-border-bottom-right-radius:3px;
  95.     border-bottom-right-radius:3px;
  96. }
  97. table tr:hover td {
  98.     background: #f2f2f2;
  99.     background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#f0f0f0));
  100.     background: -moz-linear-gradient(top,  #f2f2f2,  #f0f0f0); 
  101. }
  102. .btn {
  103.   background: #3498db;
  104.   background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
  105.   background-image: -moz-linear-gradient(top, #3498db, #2980b9);
  106.   background-image: -ms-linear-gradient(top, #3498db, #2980b9);
  107.   background-image: -o-linear-gradient(top, #3498db, #2980b9);
  108.   background-image: linear-gradient(to bottom, #3498db, #2980b9);
  109.   -webkit-border-radius: 28;
  110.   -moz-border-radius: 28;
  111.   border-radius: 28px;
  112.   font-family: Arial;
  113.   color: #ffffff;
  114.   font-size: 20px;
  115.   padding: 10px 20px 10px 20px;
  116.   text-decoration: none;
  117. }
  118.  
  119. .btn:hover {
  120.   background: #3cb0fd;
  121.   background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
  122.   background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
  123.   background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
  124.   background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
  125.   background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
  126.   text-decoration: none;
  127. }
  128. </style>
  129. <?php
  130.  
  131. /**
  132.  * Mysqli initial code
  133.  *
  134.  * User permissions of database
  135.  * Create, Alter and Index table, Create view, and Select, Insert, Update, Delete table data
  136.  *
  137.  * @package         PhpFiddle
  138.  * @link            http://phpfiddle.org
  139.  * @since           2012
  140. */
  141.  
  142. require_once "dBug!.php";
  143.  
  144. require "util/public_db_info.php";
  145.            
  146. $short_connect = new mysqli($host_name, $user_name, $pass_word, $database_name, $port);
  147.  
  148. //get all tables in the database
  149. //$sql = "SHOW TABLES";
  150.  
  151. //get column information from a table in the database
  152. //$sql="SELECT COLUMN_KEY, COLUMN_NAME, COLUMN_TYPE FROM information_schema.COLUMNS WHERE TABLE_NAME = 'books'";
  153.  
  154. //SQL statement for a table in the database
  155. $sql = "SELECT * FROM komentar";   
  156. ?>
  157. <a href="add.php" class="btn">Add Komenter</a>
  158. <table cellspacing='0'> <!-- cellspacing='0' is important, must stay -->
  159.  
  160.     <!-- Table Header -->
  161.     <thead>
  162.         <tr>
  163.             <th>#</th>
  164.             <th>Nama</th>
  165.             <th>Komentar</th>
  166.             <th>Action</th>
  167.         </tr>
  168.     </thead>
  169.     <!-- Table Header -->
  170.     <!-- Table Body -->
  171.     <tbody>
  172. <?php
  173. //result is boolean for query other than SELECT, SHOW, DESCRIBE and EXPLAIN
  174. $result = $short_connect->query($sql);
  175.  
  176. if (($result) && ($result->num_rows > 0))
  177. {
  178.     $results = array();
  179.  
  180.     //convert query result into an associative array
  181.     while ($row = $result->fetch_assoc())
  182.     {
  183.         ?>
  184.         $results[] = $row;
  185.  
  186.         <tr>
  187.             <td><input type="checkbox" name="id[]" value="<?php echo $row['id'];?>"></td>
  188.             <td><?php echo $row['nama'];?></td>
  189.             <td><?php echo $row['komentar'];?></td>
  190.             <td><a href="edit.php?id=<?php echo $row['id'];?>" class="btn">Edit</a><a href="delete.php?id=<?php echo $row['id'];?>" class="btn">Delete</a></td>
  191.         </tr><!-- Table Row -->
  192.         <?php
  193.     }
  194.     ?>
  195.     <?php
  196.  
  197.     //dump all data from associative array converted from query result
  198.     new dBug($results);  
  199.  
  200.     $result->free();
  201.  
  202. }else{
  203.     ?>
  204.         <tr>
  205.             <td colspan="4">Data Kosong</td>
  206.         </tr><!-- Table Row -->
  207.     <?php
  208. }
  209.  
  210. $short_connect->close();
  211. ?>
  212.     </tbody>
  213. </table>
Advertisement
Add Comment
Please, Sign In to add comment