## dsn stands for "data source network" $dsn = "mysql:host=localhost;port=3306;dbname=myapp;user=root; password=;charset=utf8mb4"; ## Create an instance of PDO class. $pdo = new PDO($dsn); ## we prepared new query to send to mysql $statement = $pdo->prepare("select * from posts"); ## Execute the prepared statement $statement->execute(); ## mysql executed that query $posts = $statement->fetchAll(PDO::FETCH_ASSOC); ## PDO::FETCH_ASSOC displays result in more readable format. ## (as an associative array) ## we looped over and display results foreach($posts as $post){ echo "<li>" . $post['title'] . "</li>"; }