Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>db_connect</title>
- </head>
- <body>
- CONNECT TO DB
- <?php
- try {
- $connect = new PDO('sqlite:database.db');
- $request = "select * from data";
- $stmt = $connect->prepare($request);
- $stmt->execute();
- $data = $stmt->fetchAll();
- print '<br><table><th>id</th><th>name</th><th>surname</th><th>years old</th>';
- foreach ($data as $col) {
- print '<tr>';
- foreach ($col as $value) {
- print '<td>'.$value.'</td>';
- }
- print '</tr>';
- }
- print '</table>';
- } catch (PDOexception $e) {
- print "Couldn't conenct to db ".$e->getMessage();
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement