MyBB Community Forums

Full Version: Multipage wont work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have problem with creating multipage in my custom mybb php page...
Can anybody please give me some advice or help?
I can see selection where is all pages but when i want to go to page 2 or 3 then nothing happens .. it wont change rows..

<?php    
?>

so nobody know what cause the problem
I think the issue is most likely the LIMIT clause in your. You should use something like this:
if($mybb->input['page'])
{
$page = intval($mybb->input['page']);
}
else
{
$page = 1;
}
$perpage = 20; // Change 20 to however many per page you want to display.
$start = $page * $perpage - $perpage;
$query = $db->simple_select("table_name", "columns", "conditions", array("order_by" => "whatever_field", "order_dir" => "ASC" or "DESC", "limit_start" => $start, "limit" => $perpage));
while($data = $db->fetch_array($query))
{
// code here
}
do i need to use simple_select function?
If you are including global.php, there is no need to define the database details again or connect to that database unless it is different from the one your forum uses. You also don't need to do if(!$query) because if a query has an error, it automatically stops running the script.

You also don't seem to be defining the variable $pages properly. A proper way to determine how many pages can be done like this:
$countquery = $db->simple_select("data", "COUNT(bid) as total");
$total = $db->fetch_field($countquery, "total");
$pages = ceil($total / $perpage);

Make sure that is after $perpage is defined.

simple_select is generally used if you don't need to use table joins. It doesn't have to be used, but it is easier.
i changed these things but now its not showing me multipage selection anymore.
Because you put $pages before the variable $total is defined.
Thanks Big Grin now it works fine but its shows only 2 page but there need to be lots of more pages than 2
It shows the pagination links based on two criteria. The first is how many pages there were ( $pages ). The second is based on the setting in the ACP on how many pages should be shown in pagination links.
yea, now it works fine, thank you very much dragonexpert.