Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 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. $categories = array ("id", "username");
  31.  
  32. // Create connection
  33. $conn = new mysqli($servername, $username, $password, $db);
  34.  
  35. // Check connection
  36. if ($conn->connect_error) {
  37. die("Connection failed: " . $conn->connect_error);
  38. }
  39. foreach ($tables as $tbl ) {
  40. $sql = "SELECT id, username, password, serial FROM ". $tbl;
  41. echo "<tr><th>". $tbl. "</th>";
  42. foreach ($categories as $cat) {
  43. echo "<th>".$cat."</th>";
  44. }
  45. echo "</tr>";
  46.  
  47. $result = $conn->query($sql);
  48.  
  49. if ($result->num_rows > 0) {
  50. while ($row = $result->fetch_assoc()){
  51. foreach ($row as $index=>$value) {
  52. foreach ($categories as $cat) {
  53. if ($index !== "id") {
  54. echo "<tr>";
  55. }
  56. $id;
  57. $usr;
  58. if ($row == "id")
  59. $id = $value;
  60. if ($row == "username")
  61. $usr = $value;
  62.  
  63. if ($index == $cat) {
  64. echo "<td>$id</td>";
  65. echo "<td>$usr</td>";
  66. }
  67. echo "</tr>";
  68. }
  69. }
  70. }
  71. }
  72. else {
  73. echo "0 result";
  74. }
  75. }
  76. $conn->close();
  77. echo "</table>";
  78. ?>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement