aboutsummaryrefslogtreecommitdiff
path: root/querydb.php
diff options
context:
space:
mode:
Diffstat (limited to 'querydb.php')
-rw-r--r--querydb.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/querydb.php b/querydb.php
new file mode 100644
index 0000000..dade409
--- /dev/null
+++ b/querydb.php
@@ -0,0 +1,17 @@
+<?php
+$user = "example_user";
+$password = "password";
+$database = "example_database";
+$table = "todo_list";
+
+try {
+ $db = new PDO("mysql:host=localhost;dbname=$database", $user, $password);
+ echo "<h2>TODO</h2><ol>";
+ foreach($db->query("SELECT content FROM $table") as $row) {
+ echo "<li>" . $row['content'] . "</li>";
+ }
+ echo "</ol>";
+} catch (PDOException $e) {
+ print "Error!: " . $e->getMessage() . "<br/>";
+ die();
+}