diff options
author | Mateja <mail@matejamaric.com> | 2021-04-03 00:37:03 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2021-04-03 00:37:03 +0200 |
commit | a945feb02f6d64df2219ea1044251a7fe2ea98fc (patch) | |
tree | fe0242495eb35317fd5358e403a047657dfa04b5 /querydb.php | |
download | misc-a945feb02f6d64df2219ea1044251a7fe2ea98fc.tar.gz misc-a945feb02f6d64df2219ea1044251a7fe2ea98fc.zip |
Initial commit.
Diffstat (limited to 'querydb.php')
-rw-r--r-- | querydb.php | 17 |
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(); +} |