Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <style>
- table {
- font-family: arial, sans-serif;
- border-collapse: collapse;
- width: 100%;
- }
- td, th {
- border: 1px solid #dddddd;
- text-align: left;
- padding: 8px;
- }
- tr:nth-child(even) {
- background-color: #dddddd;
- }
- </style>
- </head>
- <body>
- <?php
- echo "<table style='width:100%'>";
- $servername = "localhost";
- $username = "****";
- $password = "****";
- $db = "LVDM";
- $tables = array ("userinfo");
- $categories = array ("id", "username");
- // Create connection
- $conn = new mysqli($servername, $username, $password, $db);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- foreach ($tables as $tbl ) {
- $sql = "SELECT id, username, password, serial FROM ". $tbl;
- echo "<tr><th>". $tbl. "</th>";
- echo "</tr>";
- foreach ($categories as $cat) {
- echo "<th>".$cat."</th>";
- }
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- while ($row = $result->fetch_assoc()){
- foreach ($row as $index=>$value) {
- if ($index !== "id") {
- echo "<tr>";
- }
- $id;
- $usr;
- if ($index == "id")
- $id = $value;
- if ($index == "username")
- $usr = $value;
- if ($index == $cat) {
- echo "<td>$id</td>";
- echo "<td>$usr</td>";
- }
- echo "</tr>";
- }
- }
- }
- else {
- echo "0 result";
- }
- }
- $conn->close();
- echo "</table>";
- ?>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement