Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. table {
  5.     font-family: arial, sans-serif;
  6.     border-collapse: collapse;
  7.     width: 100%;
  8. }
  9.  
  10. td, th {
  11.     border: 1px solid #dddddd;
  12.     text-align: left;
  13.     padding: 8px;
  14. }
  15.  
  16. tr:nth-child(even) {
  17.     background-color: #dddddd;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22.  
  23.     <?php
  24.         echo "<table style='width:100%'>";
  25.         $servername = "localhost";
  26.         $username = "*****";
  27.         $password = "*****";
  28.         $db = "Ragnarok";
  29.         $tables = array ("userinfo");
  30.        
  31.         // Create connection
  32.         $conn = new mysqli($servername, $username, $password, $db);
  33.  
  34.         // Check connection
  35.         if ($conn->connect_error) {
  36.             die("Connection failed: " . $conn->connect_error);
  37.         }
  38.        
  39.         foreach ($tables as $tbl ) {
  40.             $sql = "SELECT id, username, password, serial FROM ". $tbl;
  41.             echo "<tr><th>". $tbl. "</th></tr>";
  42.             echo
  43.             "<tr>
  44.                 <th>id</th>
  45.                 <th>username</th>
  46.                 <th>password</th>
  47.                 <th>serial</th>
  48.             </tr>  
  49.             ";
  50.            
  51.             $result = $conn->query($sql);
  52.            
  53.             if ($result->num_rows > 0) {
  54.                 while ($row = $result->fetch_assoc()){
  55.                     foreach ($row as $index=>$value) {
  56.                        
  57.                         echo
  58.                         "<tr>
  59.                             <td>$value</td>
  60.                         </tr>" . "\n";
  61.                     }
  62.                 }
  63.             }
  64.             else {
  65.                 echo "0 result";
  66.             }
  67.         }  
  68.         $conn->close();
  69.     echo "</table>";   
  70.     ?>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement