note 130155 added to language.basic-syntax
| From: | Anonymous | Date: | Tue, 18 Mar 2025 06:02:28 +0000 |
| Subject: | note 130155 added to language.basic-syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221987@lists.php.net to get a copy of this message | ||
<?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/bootstrap@5.3.3/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/language.basic-syntax.php
Edit -- https://main.php.net/note/edit/130155
Del: integrated -- https://main.php.net/note/delete/130155/integrated
Del: useless -- https://main.php.net/note/delete/130155/useless
Del: bad code -- https://main.php.net/note/delete/130155/bad+code
Del: spam -- https://main.php.net/note/delete/130155/spam
Del: non-english -- https://main.php.net/note/delete/130155/non-english
Del: in docs -- https://main.php.net/note/delete/130155/in+docs
Del: other reasons-- https://main.php.net/note/delete/130155
Reject -- https://main.php.net/note/reject/130155
Search -- https://main.php.net/manage/user-notes.php