Last active
November 25, 2024 13:16
-
-
Save kjartan/7a012abc02e59dfa8cc202e4c96606aa to your computer and use it in GitHub Desktop.
Synced via Snip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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