Okay, so basically my news-like site is supposed to print out article data saved in the database. It does that quite alright, except on the 3rd article (number 2 in SQL rows or columns. whichever it is. I have my counter subtract 1 from the start article to compensate for MySQL)
My code:
<?php
print "<div class = 'menu' align='center'>Newest Stories</div>";
if (isset($_REQUEST['mstart']))
{
$start=$_REQUEST['mstart'];
}
else
{
$start=1;
}
if ($start)
{
$start=1;
}
$start--;
$end=$start+5;
$stories = mysql_query("SELECT * FROM stories ORDER BY id DESC LIMIT $start, $end") or die(mysql_error());
$num = mysql_num_rows($stories);
$start++;
if ($num > 0)
{
if ($num<$end)
{
$end = $end-(5-$num);
}
print "<b><i>Showing stories $start to $end</i></b>";
for ($count=0; $count<$num; $count++)
{
print "<hr>";
$story = mysql_fetch_array($stories,$count);
$id = $story['id'];
$headline = $story['headline'];
$author = $story['author'];
$desc = $story['description'];
$content = $story['content'];
print "COUNT: $count OF $num ($id)<br>";
print "<a href='index.php?request=story&mstart=$start&story=$id' class='headlinelink'>$headline</a><br>";
print "<div class='author'>Posted by: <a href='index.php?request=author&mstart=$start&author=$author' class='author'>$author</a>.</div>";
print "<div class='desc'>$desc</div><br>";
}
}
else
{
print "Error. No stories found. ";
}
?>
Output: (The COUNT x OF y was to help me figure out what is wrong. In the () by it is the id number of the corresponding MySQL row/column. I even deleted one of the articles to see if it was a specific article error. No luck.)