[英]PHP news system with mysql?
我正在嘗試在php中創建一個新聞系統。 數據庫結構如下所示
"title" "author" "content"
PHP腳本如下所示
<?php
include ('config2.php');
$result = mysql_query("select * from news");
while($row = mysql_fetch_array($result)) {
$title = $row['title'];
$author = $row['author'];
$content = $row['content'];
}
echo"<div class=\"post\">
<h2 class=\"title\"><font color=\'#1e1e1e\' href=\"#\">$title</font></h2>
<p class=\"meta\">Today <a href=\"#\">$author</a></p>
<p>$content</p>
</ul>
</div>"
?>
我想要做的是:每次在數據庫中插入新行時,我都希望該新行顯示在頁面上,現在,當我添加新行時,只需編輯先前的新行即可。 任何想法?
將echo
語句放入 while
循環中。
你echo
荷蘭國際集團外while
循環。 修改為以下內容:
while($row = mysql_fetch_array($result)) {
$title = $row['title'];
$author = $row['author'];
$content = $row['content'];
echo"<div class=\"post\">
<h2 class=\"title\"><font color=\'#1e1e1e\' href=\"#\">$title</font></h2>
<p class=\"meta\">Today <a href=\"#\">$author</a></p>
<p>$content</p>
</ul>
</div>";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.