[SOLVED] Pagination Page Error (no page numbers displaying)
Moderator: General Moderators
Pagination Page Error (no page numbers displaying)
[this error fixed, scroll to most recent post for next]
Last edited by jonas on Fri Jul 16, 2004 4:17 pm, edited 1 time in total.
A couple things maybe. Looking at this code in Xemacs, I think you're missing a closing bracket. I'd also recommend using heredocs as opposed to print() and escaping all the double quotes. It'll make your life SO much easier not having to escape stuff all the time.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Ok I fixed it. Now I'm trying to get the pagination to work properly.... it only displays the amount it's supposed to which is great but I'm not getting any page numbers to navigate to the next pages.
Test URL: http://forums.bolt3.com/topiclist.php?forumID=117
This is the topics being displayed and there is 12 in the DB.
This is my updated code:
How do I get the page numbers to show up
Test URL: http://forums.bolt3.com/topiclist.php?forumID=117
This is the topics being displayed and there is 12 in the DB.
This is my updated code:
Code: Select all
<?
include("../dbconnection/connect_db.inc.php");
$query = "SELECT * FROM forums where forumID='$forumID'";
$mysql_stuff = mysql_query($query, $mysql_link);
while($roc = mysql_fetch_row($mysql_stuff)){
$gameID = $roc[1];
$forum_name = $roc[2];
}
function nextpage($table,$perpage,$start,$page, $query)
{
$start = (int)$start;
$query = "SELECT count(*) as count FROM $table $query";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row[0];
//
//
$b_link = "<<";
if($start > 0)
{
$b_link = "<a href="".$page."&start=".($start - $perpage).""><<</a>";
}
$r .= "$b_link ";
//
$pages = ceil($numrows / $perpage);
$current_page = ceil($start / $perpage) + 1;
$link = 1;
$s = 0;
for($ba = 1; $ba <= $pages; $ba++)
{
$li = "<a href="$page&start=$s">$link</a> ";
if($ba == $current_page)
{
$li = "<b>$ba</b> ";
}
$page_links .= $li;
$s = $perpage * $link;
$link++;
}}
if (empty($forumID)){
print("
<html>
<head>
<title>Bolt 3 - Error</title>
</head>
<body bgcolor="#DAD6B0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<link href="css.php" rel="stylesheet" type="text/css">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">"); include('../header.php'); print("</td>
</tr>
<tr>
<td valign="top">
<div align="center">
<table width="778" class="contenttable" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" height="100%" class="contentinside">
<tr>
<td valign="top">
<div align="center">
<br>
<table class="regpart1" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
<br>
You did not specify a game.<br>
<br>
</div>
</table>
</div>
<br>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>"); include('../footer.php'); print("</td>
</tr>
</table>
</body>
</html>");
} else {
print("
<html>
<head>
<title>Bolt 3 - $forum_name Forum</title>
</head>
<link href="css.php" rel="stylesheet" type="text/css">
<body bgcolor="#DAD6B0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">"); include('../header.php'); print("</td>
</tr>
<tr>
<td>
<div align="center">
<table width="778" class="contenttable" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
<table width="100%" height="100%" class="contentinside">
<tr>
<td>
<div align="center">
<table width="768" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
<table width="598" border="0" cellpadding="0" cellspacing="0">
<tr style='background-color:#6D6B57;'>
<td colspan="3"><div align="center"><font color="#FFFFFF" size="3" face="Verdana, Arial, Helvetica, sans-serif">
<b>$forum_name</b>
</font></div></td>
</tr>
</table>
</div>
</td>
</tr><table width="598" border="1" cellpadding="0" cellspacing="0" bordercolor="#6D6B57">");
$start = (int)$_GET['start'];
$perpage = 5;//change this to whatever number you like.
$query = mysql_query("SELECT * FROM forum_topics where forumID='$forumID' limit $start, $perpage");
while($data = mysql_fetch_array($query)){
$color = ($roc_bool)?"#9F9C7E":"#A8A58D";
$color1 = ($roc_bool)?"#A8A58D":"#9F9C7E";
$roc_bool = !$roc_bool;
$memberID = $data[2];
$topic_title = $data[4];
$topic_lastpost = $data[5];
$topic_dateposted = $data[6];
$topic_timeposted = $data[7];
print("<tr style='background-color:$color;'><td><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">$topic_title</font></td><td><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">$memberID</font></td><td><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">by: $topic_lastpost</font></td></tr>");
}
echo "<tr>"."<td>".nextpage("forum_topics",$perpage,$start,$_SERVER['PHP_SELF'], "where forumID='$forumID'")."</td>"."</tr>";
print("</table>
<tr>
<td>
<div align="center">
<table width="598" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20" border="0" bgcolor="#6D6B57"><div align="left"><img src="http://www.bolt3.com/siteimages/tf-left.gif"></div></td>
<td bgcolor="#6D6B57"><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><a class="header" href="gameinfo.php?gameID=$gameID">Info</a> | <a class="header" href="codes.php?gameID=$gameID">Codes/Secrets</a> | <a class="header" href="hints.php?gameID=$gameID">Hints/Glitches</a> | <a class="header" href="faqs.php?gameID=$gameID">FAQs/Walkthroughs</a> | <a class="header" href="http://forums.bolt3.com/topiclist.php?forumID=$forumID">Forum</a></font></div></td>
<td width="20" border="0" bgcolor="#6D6B57"><div align="right"><img src="http://www.bolt3.com/siteimages/tf-right.gif"></div></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>"); include('../footer.php'); print("</td>
</tr>
</table>
</body>
</html>");
}
?>How do I get the page numbers to show up
Code: Select all
<?php
function nextpage($table,$perpage,$start,$page, $query)
{
$start = (int)$start;
$query = "SELECT count(*) as count FROM $table $query";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row[0];
$b_link = "<<";
if($start > 0)
{
$b_link = "<a href="".$page."&start=".($start - $perpage).""><<</a>";
}
$r .= "$b_link ";
$pages = ceil($numrows / $perpage);
$current_page = ceil($start / $perpage) + 1;
$link = 1;
$s = 0;
for($ba = 1; $ba <= $pages; $ba++)
{
$li = "<a href="$page&start=$s">$link</a> ";
if($ba == $current_page)
{
$li = "<b>$ba</b> ";
}
$page_links .= $li;
$s = $perpage * $link;
$link++;
}
$f_link = ">>";
if($numrows > ($start + $perpage))
{
$f_link = " <a href="".$page."&start=".($start + $perpage)."">>></a>";
}
$r .= "$page_links $f_link<br />Displaying Page ".($current_page)." of $pages<br /></b></font>\n\n\n";
if($numrows != 0)
{
return $r;
}
}
?>Cool. I replaced my code with that.
http://forums.bolt3.com/topiclist.php?forumID=117
The only thing is when I click page 2 or 3 or the next page arrows it says page cannot be displayed.
I need to submit the forumID to the next page to get it to display properly. How would I do this properly?
I need it to go to http://forums.bolt3.com/topiclist.php?f ... 17&start=5 (or whatever)
and right now its just going to http://forums.bolt3.com/topiclist.php&start=5
Thanks (this should be the last problem
)
http://forums.bolt3.com/topiclist.php?forumID=117
The only thing is when I click page 2 or 3 or the next page arrows it says page cannot be displayed.
I need to submit the forumID to the next page to get it to display properly. How would I do this properly?
I need it to go to http://forums.bolt3.com/topiclist.php?f ... 17&start=5 (or whatever)
and right now its just going to http://forums.bolt3.com/topiclist.php&start=5
Thanks (this should be the last problem
Last edited by jonas on Fri Jul 16, 2004 6:48 pm, edited 1 time in total.