[PHP-NOTES] note 130169 added to faq.general

[email protected] ("Anonymous")
Newsgroups php.notes
Message-ID <[email protected]>
<?php
     $servername = "mysql";
     $username = "root";
     $password = "htlkrems";
     $dbname = "blog_system";

     try {
     $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
     // set the PDO error mode to exception
     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     echo "Connected successfully";
     } catch(PDOException $e) {
     echo "Connection failed: " . $e->getMessage();
     }

     $sql= "SELECT * FROM posts";
     $stmt = $conn->prepare($sql);
     $stmt ->execute();
     $results = $stmt -> fetchAll(PDO::FETCH_ASSOC);

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <title>Document</title>
</head>
<body>
    <?php
        if(count($results)){
            echo"<table class='table table-striped'>";
                echo"<tr>

                <th>Titel</th>
                <th>Author</th>
                <th>Publish Date</th>
                <th>Comment</th>

                    </tr>";
            
            foreach($results as $row){
                echo"<tr>";
                    echo"<td>".$row['title'] ."</td>";
                    echo"<td>".$row['author'] . "</td>";
                    echo"<td>".$row['publish_date'] . "</td>";
                    echo"<td><a href='index2.php?id=" . urlencode($row['id'])."'><img src='icon.png' width ='40px'></a></td>";
                echo"</tr>";    
            }
            echo"</table>";
        }
    ?>
</body>
</html>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 193.170.70.42)
----
Manual Page -- https://php.net/manual/en/faq.general.php
Edit        -- https://main.php.net/note/edit/130169
Del: integrated  -- https://main.php.net/note/delete/130169/integrated
Del: useless     -- https://main.php.net/note/delete/130169/useless
Del: bad code    -- https://main.php.net/note/delete/130169/bad+code
Del: spam        -- https://main.php.net/note/delete/130169/spam
Del: non-english -- https://main.php.net/note/delete/130169/non-english
Del: in docs     -- https://main.php.net/note/delete/130169/in+docs
Del: other reasons-- https://main.php.net/note/delete/130169
Reject      -- https://main.php.net/note/reject/130169
Search      -- https://main.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.