<?php
try{
$dbh = new PDO('mysql:dbname=blog;host=localhost', 'root', '');
} catch (PDOException $e) {
die($e->getMessage());
}
$sth = $dbh->prepare("SELECT * FROM `pages` ORDER BY `name`");
$sth->execute();
$array = $sth->fetchAll();
foreach ($array as $result_row) {
echo ($result_row["name"]);
echo ($result_row["id"]);
echo ($result_row["author"]);
echo ($result_row["date"]);
echo '<td><a href="code.php?id="' . $result_row['id'] . '">Edit</a></td>';
}
?>
<?php
try{
$dbh = new PDO('mysql:dbname=blog;host=localhost', 'root', '');
} catch (PDOException $e) {
die($e->getMessage());
}
//$idka = $_GET["id"];
$sth = $dbh->prepare("SELECT content FROM `pages` where id = ?");
$sth->execute([$_GET["id"]]);
$result_row = $sth->fetch();
echo htmlspecialchars($result_row["content"]);
?>
Работа с БД по большей части...