Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "root";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=Test", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- ?>
- <html>
- <table width="600" border="1" cellpadding="1" cellspacing="1">
- <tr>
- <!-- 3 rows of information is supposed to be printed out; Spillnavn, Utgivelsesdato, Kommentar-->
- <th>Spillnavn</th>
- <th>Utgivelsesdato</th>
- <th>Kommentar</th>
- </tr>
- <tr>
- <?php
- $get = $conn->prepare("SELECT * FROM kjartan ORDER BY Utgivelsesdato DESC");
- $get->execute();
- while ($kjartan = $get->fetch()){
- echo "<tr>";
- echo "<td>".$kjartan['Spillnavn']."</td>";
- echo "<td>".$kjartan['Utgivelsesdato']."</td>";
- echo "<td>".$kjartan['Kommentar']."</td>";
- echo "</tr>";
- }
- ?>
- </tr>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement