Created
October 26, 2022 17:29
-
-
Save JeffreyWay/2371cd20b38888ef67241e228723deab to your computer and use it in GitHub Desktop.
This file contains 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 | |
// Connect to the MySQL database. | |
$dsn = "mysql:host=localhost;port=3306;dbname=myapp;user=root;charset=utf8mb4"; | |
// Tip: This should be wrapped in a try-catch. We'll learn how, soon. | |
$pdo = new PDO($dsn); | |
$statement = $pdo->prepare("select * from posts where id = 1"); | |
$statement->execute(); | |
$post = $statement->fetch(PDO::FETCH_ASSOC); | |
echo "<li>" . $post['title'] . "</li>"; |
This file contains 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 | |
require 'functions.php'; | |
// Connect to the MySQL database. | |
$dsn = "mysql:host=localhost;port=3306;dbname=myapp;user=root;charset=utf8mb4"; | |
// Tip: This should be wrapped in a try-catch. We'll learn how, soon. | |
$pdo = new PDO($dsn); | |
$statement = $pdo->prepare("select * from posts"); | |
$statement->execute(); | |
$posts = $statement->fetchAll(PDO::FETCH_ASSOC); | |
foreach ($posts as $post) { | |
echo "<li>" . $post['title'] . "</li>"; | |
} |
Thankful for discussing the homework information.and in my words It means to do a work at home. It helps the students to check their mistakes and by reading they can correct their pronunciation. Ordering a research paper can be a useful solution for students pressed for time, visit here https://academized.com/order-research-paper but choosing a reliable service is crucial. Look for companies with positive reviews, experienced writers, and a clear revision policy while convenient
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
//connection with mysql
$dns = "mysql:host=localhost;dbname=myapp;user=root;charset=utf8mb4";
$pdo = new PDO($dns);
$statement = $pdo->prepare("select * from posts where id=1");
$statement->execute();
$post = $statement->fetch(PDO::FETCH_ASSOC);
echo "