Paging Issue

Hello,
Can anyone spot any errors in my code for paging to work. I want to show 5 results and then be able to search page by page for any older results. :oThanks
[php]$query = “SELECT count(pictureid) from postings where pictureid = $pictureid”;
$result = mysql_query($query);
$row=mysql_fetch_array($result);
if ($row[00] == 0)
{
echo “

Sorry, there are no postings posted at this time, please try back later.

”;
} else
{

$totrecords = $row[0];
if (!isset($_GET[‘page’]))
$thispage = 1;
else
$thispage = $_GET[‘page’];
$recordsperpage = 5;
$offset = ($thispage - 1) * $recordsperpage;
$totpages = ceil($totrecords / $recordsperpage);
$query = “SELECT pictureid,title,poster,picture,shortdesc from postings order by pictureid desc LIMIT $offset, $recordsperpage”;

$result = mysql_query($query) or die('Sorry, could not get postings at this time ');
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$pictureid = $row[‘pictureid’];
$title = $row[‘title’];
$poster = $row[‘poster’];
$picture = $row[‘picture’];
$shortdesc = $row[‘shortdesc’];

echo “<a href=“index.php?content=showposting&id=$pictureid”>

$title

submitted by • $poster
\n”;
echo “$shortdesc
\n”;
echo “<img src=“showimage.php?id=$pictureid” height=“390”>

\n”;
}
if ($thispage > 1)
{
$page = $thispage - 1;
$prevpage = “<a href=“index.php?content=showposting&id=$pictureid&page=$page”>Prev”;
} else
{
$prevpage = " ";
}
if ($totpages > 1)
{
$bar = ‘’;
for($page = 1; $page <= $totpages; $page++)
{
if ($page == $thispage)
{
$bar .= " $page ";
} else
{
$bar .= " <a href=“index.php?content=showposting&id=$pictureid&page=$page”>$page “;
}
}
}
if ($thispage < $totpages)
{
$page = $thispage + 1;
$nextpage = " <a href=“index.php?content=showposting&id=$pictureid&page=$page”>Next”;
} else
{
$nextpage = " ";
}
echo "GoTo: " . $prevpage . $bar . $nextpage;
}[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service