The table with the threads in is called f_threads, and the table with the posts in (including the first) is called f_posts.
This is the code for the pagination (tabs don't seem to work well):
Code: Select all
<?php
if(isset($_GET["page"])) //forumview.php?id=1&[b]page=1[/b], for ex.
{
$page = $_GET["page"];
$limit = 3; //A weird limit, just for testing
$lstart = $page * $limit - ($limit);
}
else
{
$page = 1;
$limit = 3;
$lstart = $page * $limit - ($limit);
}
$sql = "SELECT f_threads.*, f_posts.date, f_posts.thread FROM f_threads INNER JOIN f_posts ON f_posts.thread = f_threads.id AND f_threads.forum = ".$_GET['id']." ORDER BY date DESC LIMIT ".$lstart.", ".$limit; //Selecting everything I need to output later, isn't shown in this part of the page
$result = mysql_query("$sql");
$sqlc = "SELECT COUNT(*) FROM f_threads"; //FROM HERE
$resultc = mysql_query("$sqlc");
$totalrows = mysql_num_rows($resultc); //TO HERE is what I think messes things up
echo $totalrows."<table width='100%' class='sometables'><tr><td class='bsometds' align='center' colspan='5'>"; //Start the output table, ended later in another part of the page. I echoed $totalrows just to see what it is
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++) //This for loop prints the page numbers
{
if($i == $page)
{
echo "[".$i."]";
}
else
{
echo "[<a href='forumview.php?id=".$_GET['id']."&page=".$i."'>".$i."</a>]";
}
}
if($totalrows % $limit != 0) //This if prints the last number in some cases
{
if($i == $page)
{
echo "[".$i."]";
}
else
{
echo "[<a href='forumview.php?id=".$_GET['id']."&page=".$i."'>".$i."</a>]";
}
}
echo $numofpages."</td></tr>"; //I echoed $numofpages just to see what it is
?>Can you help?