【发布时间】:2019-08-01 17:30:25
【问题描述】:
我正在创建一个 PHP 新闻门户。如何为我发布的每个帖子自动创建一个新页面(带有页眉和页脚)?
我正在尝试使用 fopen/fclose 来执行此操作,但我不知道如何从数据库 (MySQL) 中获取帖子的 ID 并使其显示在 URL 上。现在是这样的:
<?php
$myFile = "new_article.php";
$fh = fopen($myFile, 'w') or die("error");
$stringData = '
<?php include "header.php";?>
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>test</title></head>
</html>
<?php include "footer.php";?>
';
fwrite($fh, $stringData);
fclose($fh);
?>
【问题讨论】:
-
您需要了解如何进行 SQL 查询,以及如何在 PHP 中利用结果。你不是在问一个具体的问题,而是在编写代码时寻求帮助。