Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>db_connect</title>
  5. </head>
  6. <body>
  7. CONNECT TO DB
  8. <?php
  9. try {
  10. $connect = new PDO('sqlite:database.db');
  11. $request = "select * from data";
  12. $stmt = $connect->prepare($request);
  13. $stmt->execute();
  14. $data = $stmt->fetchAll();
  15. print '<br><table><th>id</th><th>name</th><th>surname</th><th>years old</th>';
  16. foreach ($data as $col) {
  17. print '<tr>';
  18. foreach ($col as $value) {
  19. print '<td>'.$value.'</td>';
  20. }
  21. print '</tr>';
  22. }
  23. print '</table>';
  24. } catch (PDOexception $e) {
  25. print "Couldn't conenct to db ".$e->getMessage();
  26. }
  27. ?>
  28. </body>
  29. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement