我试图获取每个帖子的帖子ID,但内容没有出现。有人能指出我正确的方向吗?
的index.php
<?php
include 'main.php';
include 'dbconnect.php';
$findPosts = "SELECT * FROM Posts ORDER BY Date DESC";
$showPosts = mysqli_query($db, $findPosts) or die(mysqli_error);
while ($currentrow = mysqli_fetch_array($showPosts)) {
//echo each post title as a link contained in a div box.//
echo '<div class="box">';
echo '<a href="view_post.php" class="PostTitle">'.$currentrow['Title'].'</a>';
echo '<p class="Date">'.$currentrow['Date'].'</p>';
echo '</div>';
}
?>
每个链接的目标属性为 view_post.php
<?php
include "dbconnect.php";
include "main.php";
$post_id = $_POST['ID'];
$sql = "SELECT * FROM Posts WHERE ID = '".$post_id."' LIMIT 1";
$res = mysqli_query($sql) or die(mysqli_error());
if (mysql_num_rows($res) == 1) {
//Echo a table containing each post's title, content and date.//
echo "<tr><td valign='top' style='border: 1px solid #000000;'><div style='min-height: 125px;'>".$row['Title']."<br />
-".$row['Date']."<hr />".$row['Content']."</div></td><td width: '200px' valign='top' align='center' style='border: 1px solid #000000;'>
User Info Here</td></tr><tr><td colsplan='2'><hr /></td></tr>";
} else {
echo "<p>This post does not exist.</p>";
}
?>