Forum Moderators: coopster

Message Too Old, No Replies

PHP Paging Issues

PHP Paging Issues

         

magua100

8:31 pm on Sep 15, 2005 (gmt 0)

10+ Year Member



I am reposting this becuase i left out some important information.

I am trying to create a "Question and Answer" app
with pageing nav system that will take u to the
"first" "last" "prev" and "next" question.

I also have it set up to carry over the pageing when you click on the answer link. Now this wher things get weird.
Now the "next" link does not show up as a link even though it the IF THEN ELSE statment is satisfied.

<?
// begin Display Answer to current question along with the navigaition System
// First get and display the category

$questionID = $_GET['questionID'];
if ( empty($questionID)) {
$questionID = 0;
}
if ($questionID <> 0) {

$query = "SELECT answer FROM questions WHERE questionID = " . $questionID . "";
$result = mysql_query($query) or die('Error, query failed');

while ($row = mysql_fetch_array($result)) {
$answer = $row["answer"];

?>
<?
$catIDnav = $_GET['catIDnav'];
$query = "SELECT * FROM categories WHERE catID = " . $catIDnav . "";
$result = mysql_query($query) or die('Error, query failed. line 45');
while ($row = mysql_fetch_array($result)) {
$category= $row["category"];
echo "<h3>" . $category . "</h3><br>";
}
?>

<?
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo $answer;
echo "<br><br>";
$pageNum = $_GET['pageNum'];
$maxPage = $_GET['maxPage'];
echo "pageNum = ";
echo "$pageNum";
echo "<br>";
echo "maxPage= ";
echo "$maxPage";

echo "<br><br><br?";
$catID = $_GET['catIDnav'];

if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?page=$page&catID=$catID\">[Prev]</a> ";
$first = " <a href=\"$self?page=1&catID=$catID\">[First Page]</a> ";
}
else
{
$prev = '&nbsp;'; // IF wer are on page one, don't print previous link
$first = '&nbsp;'; // or the first page link
}

if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page&catID=$catID\">[next]</a> ";
$last = " <a href=\"$self?page=$maxPage&catID=$catID\">[last page]</a> ";

}
else
{
$next = '&nbsp;'; // we're on the last page, don't print next link
$last = '&nbsp;'; // nor the last page link
}

// print the navigation link, First last previous and next as well as which record of total recordset.
echo $first . $prev .
" $pageNum of $maxPage " . $next . $last;

?>

<?
}
}
// End Display Answer.
?>

[edited by: jatar_k at 9:40 pm (utc) on Sep. 15, 2005]
[edit reason] no urls thanks [/edit]

coopster

12:12 am on Sep 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm guessing the $next link is probably set to &nbsp; which is the *else* part of the logic. Have you tried Viewing Source to see if that is indeed the case?