mukeshdak

2025-09-29_list a column from a table

Sep 28th, 2025
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. <?php
  2. $db = new PDO("mysql:host=103.53.43.235;dbname=dunglskh_mvc_2020", "dunglskh_md", "use-real-password-here");
  3. $posts = $db->query("SELECT * FROM posts")->fetchAll();
  4. ?>
  5. <!doctype html>
  6. <html lang="en">
  7. <head>
  8.     <meta charset="UTF-8">
  9.     <meta name="viewport"
  10.           content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  11.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  12.     <title>Document</title>
  13. </head>
  14. <body>
  15. Following are my posts.
  16. <?php
  17. foreach ($posts as $post) {
  18.     echo "<h2>" . $post['title'] . "</h2>";
  19. }
  20. ?>
  21. </body>
  22. </html>
Tags: php mysql
Add Comment
Please, Sign In to add comment