Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "lbswebb_edvin";
- $password = "xZuPppi.Oi5$";
- $dbname = "lbswebb_edvin";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if($conn -> connect_error) {
- die("connection failed" . $conn->connect_error);
- }
- $sql = "SELECT id, firstname, lastname, username, password FROM user";
- $result = $conn->query($sql);
- $message = '';
- if ($result->num_rows > 0){
- while($row = $result->fetch_assoc()) {
- $message .= '
- <li class="list-group-item">id: ' .$row["id"].
- " - Name: ".$row["firstname"]." ".$row["lastname"].
- " - username: ".$row["username"].
- " - password: ".$row["password"]." </li>";
- }
- }
- else
- {
- $message = "0 results";
- }
- $conn->close();
- ?>
- <!DOCTYPE html>
- <html lang="sv">
- <head>
- <meta charset="utf-8" />
- <title>mySql</title>
- <link rel="stylesheet"
- href ="https://bootswatch.com/4/cerulean/bootstrap.min.css">
- <style>
- body {
- padding-top:16px;
- background-color : #808080 !important
- }
- .container {
- max-width: 600px
- }
- h1, h2 {
- color: rgb(255, 255, 255) !important
- </style>
- </head>
- <body>
- <a href="http://lbswebb.se/sy16/edvin/php/Uppgift/utrakning.php">Räkna ut Area med hjälp utav PHP (uppgift)</a>
- <p></p>
- <a href="http://lbswebb.se/sy16/edvin/php/Uppgift1/index.php">Uppdatera Sida med hjälp utav PHP (uppgift)</a>
- <?php echo
- '<div class="container">
- <h2 class="page-header">Users List</h2>
- <ul class="list-group">'.$message.'
- </ul>
- </div>
- ';
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement