This code is printing the 3 results on the page, but not the $pagesvar which would be used for navigation of the pages. Why won't it show?
PHP Code:<?php
$connection = mysql_connect("localhost","stickman373","******");
mysql_select_db("stickman373_uk_db");
$totalquery = "SELECT COUNT (title) FROM movie ORDER BY title";
$totalresult = mysql_fetch_row(mysql_query($totalquery));
$total = $totalresult[0]; // EDIT!
mysql_free_result($totalresult);
$perpage = 2;
if (!$page || !is_numeric($page)) $page=1;
$limit = ($page - 1) * $perpage;
$numpages = ceil($total / $perpage);
$prev = $page - 1;
$next = $page + 1;
if ($numpages > 1) {
$pagesvar = "";
if ($page - 3 > 0) $pagesvar .= "<a href='?page=1'><u><<</u></a> ";
if ($prev > 0 && $prev <= $numpages) $pagesvar .= "<a href='?page=$prev'><u><</u></a> ";
for ($i=$page-2; $i < $page; $i++) {
if ($i > 0) $pagesvar .= "<a href='?page=$i'><u>$i</u></a> ";
}
$pagesvar .= "<a>$page</a> ";
for ($i=$page+1; $i <= $page+2; $i++) {
if ($i <= $numpages) $pagesvar .= "<a href='?page=$i'><u>$i</u></a> ";
}
if ($next <= $numpages && $next > 0) $pagesvar .= "<a href='?page=$next'><u>></u></a> ";
if ($page + 3 <= $numpages) $pagesvar .= "<a href='?page=$numpages'><u>>></u></a> ";
}
$connection = mysql_connect("localhost","stickman373","redman");
mysql_select_db("stickman373_uk_db");
$query2 = "SELECT title FROM movie ORDER BY title DESC LIMIT $limit,$perpage";
$result2 = mysql_query($query2);
while ($row = mysql_fetch_array($result2)) {
echo $row['title'];
echo $pagesvar;
}
mysql_free_result($result2);
?>



Reply With Quote