Forum Moderators: coopster
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 " ";
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 = ' '; // IF wer are on page one, don't print previous link
$first = ' '; // 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 = ' '; // we're on the last page, don't print next link
$last = ' '; // 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]