| 61 | [[Image(825webdevtools.png)]] |
| 62 | |
| 63 | PHP can also be used to read SQLite databases. |
| 64 | |
| 65 | {{{ |
| 66 | root@imx8mq-var-dart:/usr/share/apache2/default-site/htdocs# cat testsqlite.php |
| 67 | <!DOCTYPE html> |
| 68 | <html lang="en"> |
| 69 | <head> |
| 70 | <title>825 SQLite Test</title> |
| 71 | </head> |
| 72 | <body> |
| 73 | |
| 74 | <?php |
| 75 | $db = new SQLite3('/mnt/nand/apps/ids/ids.db3'); |
| 76 | |
| 77 | $results = $db->query('SELECT truck_name,tare FROM trucks'); |
| 78 | echo '<table><tr><th>Truck ID</th><th>Tare</th></tr>'; |
| 79 | while ($row = $results->fetchArray()) { |
| 80 | $truckid = $row['truck_name']; |
| 81 | $tare = $row['tare']; |
| 82 | echo '<tr><td>' . $truckid . '</td><td>' . $tare . '</td></tr>'; |
| 83 | } |
| 84 | echo '</table>'; |
| 85 | ?> |
| 86 | |
| 87 | </body> |
| 88 | </html> |
| 89 | }}} |