Skip to content

Instantly share code, notes, and snippets.

@kjartan
Last active November 25, 2024 13:16
Show Gist options
  • Select an option

  • Save kjartan/7a012abc02e59dfa8cc202e4c96606aa to your computer and use it in GitHub Desktop.

Select an option

Save kjartan/7a012abc02e59dfa8cc202e4c96606aa to your computer and use it in GitHub Desktop.
Synced via Snip
<?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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment