So I’ve been working on the code below and, no matter what I do it won’t display more than the current database *=(From the URL http://www.example.com/blogs/1)
I would like it to display the last two or however many I put int he top argument.
I’ve tried switching “story id from Blogs” with “* from blogs” both work, but neither does what I’m trying to do. I have two blog entries and it only ever returns blog entry 1.
<?php
$sql2="select top 2 storyid from Blogs order by storyid desc";
//echo "$sql<br/>";
$results2=mysql_query($sql,$connection);
while ($result=mysql_fetch_assoc($results2)){
$title=$result["Title"];
$storyid=$result["storyid"];
$photo2=$result["Photo2"];
$date=$result["Date"];
?>
<li>
<img src="/images/<?php echo $photo2; ?>" alt="Blog link" />
<div class="blog-details">
<h4><a href="/blogs/<?php echo "$storyid"; ?>"><?php echo "$title"; ?></a></h4>
<p><?php print date('M d Y', strtotime($date)); ?> - <a href="#">2 Comments</a></p>
<li>
<img src="/images/<?php echo $photo2; ?>" alt="Blog link" />
<div class="blog-details">
<h4><a href="/blogs/<?php echo "$storyid"; ?>"><?php echo "$title"; ?></a></h4>
<p><?php print date('M d Y', strtotime($date)); ?> - <a href="#">2 Comments</a></p>
<?php
}
?>
Try modifying your query to use limit instead of top