这是我的第一篇文章。我已经搜索了很多,但我找不到我要找的东西。所以我有这个文件破坏了帖子的内容并阅读了更多内容:
<?php
include('../root/admin/includes/connect.php');
$sql = "SELECT * FROM posts";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
echo "\n";
echo truncate($row['Content'], "article.php", "article_id", $row['ID']);
}
//function to truncate text and show read more link
function truncate($mytext, $link, $var, $id) {
//Number of characters to show
$chars = 25;
$mytext = substr($mytext, 0, $chars);
$mytext = substr($mytext, 0, strrpos($mytext, ' '));
$mytext = $mytext . " <a href='$link?$var=$id'>read more...</a>";
return $mytext;
}
?>
现在我有了这个文件
<?php
include('includes/connect.php');
$id = isset($_GET['ID']);
$query = mysql_query("SELECT * FROM posts WHERE ID='$id'") or die(mysql_error());
if (mysql_num_rows($query) == 0) {
echo "<tr><td colspan=\"3\">No Posts Were Found</td></tr>";
} else {
while ($post = mysql_fetch_assoc($query)) {
echo "<div class='perigrama'><div class='titlos'><h2><a href='#'>" . $post['Title'] . "</a></h2></div><div class='infos'><p>Posted by <a href='#'>" . $post['Author'] . "</a> on March 10, 2011 | <a href='#'>Full article</a></p></div><div class='image'><img src='#' width='540' height='300'></div><div class='content'><p>" . $post['Content'] . "</p></div><div class='more'><p><a href='#'>Full details</a></p></div></div>";
}
}
?>
而这个文件,我想在这里根据 ID 从数据库中输出帖子,当我点击阅读更多时:
<html>
<head>
<title></title>
</head>
<link rel="stylesheet" type="text/css" href="../test/testdivformascss.css">
<body>
<?php
include('functions1.php');
?>
</body>
</html>
当我点击阅读更多时,我得到的输出是这样的,它将我重定向到正确的页面 id,但告诉我没有找到任何帖子。
如果你能告诉我如何做到这一点,我会很高兴看到它。提前致谢!