我试图获得小于我最后一个分页值的值,但我不断得到空数组,即使那里应该有值。是我的语法导致了这个还是我说错了?先感谢您。
<?php
include("connect.php"); //connect to database
//create query
$get_messages_query = $db->prepare("
SELECT * FROM `blogposts`
WHERE `postid` < ?
ORDER BY `postid` DESC
LIMIT 5
");
//Homepage should have last 5 blog posts this will take the
//last 5 entered into the database and put them into an
//array
$one = 1;
$zero = 0;
$lastpage = $_GET['id'];
$pageback = $lastpage - 1;
$pageforward = $lastpage + 1;
$get_messages_query->execute(array($_POST['idid']));
while($row = $get_messages_query->fetch())
{
if($row['comments'] == $one){
$id = $row['postid'];
$blog_post_history .=
'<div class="post" id="post">
<h1>' . $row['title'] .' </h1>
<h2>Written by: ' . $row['author'] . '</h2>
<p>'. $row['content'] . '</p>
<a href="addcomment.php?id='. $row['postid'] .'">Add Comment</a>
<a href="showcomments.php?id='. $row['postid'] . '">Show Comments</a>
<br>
<br>
</div>';
}
else{
$id - $row['postid'];
$blog_post_history .=
'<div class="post" id="post">
<h1>'. $row['title'] .' </h1>
<h2>Written by: ' . $row['author'] . '</h2>
<p>'. $row['content'] . '</p>
<a href="viewblog.php?id='. $row['postid'] .'">View Blog</a>
<br>
<br>
</div>';
}
}