Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "root";
  5. try {
  6. $conn = new PDO("mysql:host=$servername;dbname=Test", $username, $password);
  7. // set the PDO error mode to exception
  8. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  9. }
  10. catch(PDOException $e)
  11. {
  12. echo "Connection failed: " . $e->getMessage();
  13. }
  14. ?>
  15. <html>
  16. <table width="600" border="1" cellpadding="1" cellspacing="1">
  17. <tr>
  18. <!-- 3 rows of information is supposed to be printed out; Spillnavn, Utgivelsesdato, Kommentar-->
  19. <th>Spillnavn</th>
  20. <th>Utgivelsesdato</th>
  21. <th>Kommentar</th>
  22. </tr>
  23. <tr>
  24. <?php
  25. $get = $conn->prepare("SELECT * FROM kjartan ORDER BY Utgivelsesdato DESC");
  26. $get->execute();
  27. while ($kjartan = $get->fetch()){
  28. echo "<tr>";
  29. echo "<td>".$kjartan['Spillnavn']."</td>";
  30. echo "<td>".$kjartan['Utgivelsesdato']."</td>";
  31. echo "<td>".$kjartan['Kommentar']."</td>";
  32. echo "</tr>";
  33. }
  34. ?>
  35. </tr>
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement