Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.
makepagenav
Creates a fully page navigation used in the PHP-Fusion System. With the given parameters you can in a few easy steps build a page navigation for your Infusions or mods for PHP-Fusion.

makepagenav

Quote

makepagenav ( int $start, int $count, int $total [, int $range [, string $link [, string $getname ] ] ] )

Parameters
start
Is the start entry number

count
Is the number of entries displayed on one page

total
Is the total entries which should be displayed

range
is number of page buttons displayed and the range of them

link
Is the link for the navigation links

getname
Is the name of the $_GET parameter that contains the start number

Return Values
makepagenav() will return a <div> containing the navigation in PHP-Fusion 9, 7 and a <table> in PHP-Fusion 6.

Examples

Basic makepagenav example
Code
<?php
// Set the number of how many items you want to display
// at one page
$items_per_page = 10;
 
// Here we check for the $_GET['rowstart'] variable and
// set it to 0 if it is not set already
if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) {
 $_GET['rowstart'] = 0;
}
 
// Count the total number of rows in the table with the given
// condition(s). In this example the conditions are field1='this'
$rows = dbcount("(field)", TABLE_NAME, "field1='this'");
 
// Display the results from $_GET['rowstart'] and the next 10
// items ($items_per_page)
$result = dbquery(
 "SELECT field FROM ".TABLE_NAME."
 WHERE field1='this'
 LIMIT ".$_GET['rowstart'].",$items_per_page"
);
while($data = dbrows($result)) {
 // Items will go here
}
 
// If there are more rows than the number of items (10) in
// the table we display the makepagenav()
if ($rows > $items_per_page) {
 echo makepagenav($_GET['rowstart'], $items_per_page, $rows, 3);
}
 
?>

This is just a basic example on how the whole makepagenav function works.
This is the minimum you have to write and all parts are necessary. Remember that you do not need the field1='this' part in the dbquery and dbcount functions.

makepagenav on non standard pages
Code
<?php
// Here we'll use the same code from the example above
// except the line where we output the makepagenav
// function. Make sure you do not forget the &amp; at the
// end or this function will not work correctly!
 
echo makepagenav($_GET['rowstart'], $items_per_page, $rows, 3, FUSION_SELF."?this=that&amp;");
?>

Sometimes you are using the makepagenav() function on pages which is only site.php but maybe site.php?this=that which is no problem when tweaking the first example ending up with this function.

Multiple paginations on a single page
Code
<?php
// Here we'll use the same code from the example above
// except the line where we output the makepagenav
// function. Make sure you do not forget the &amp; at the
// end or this function will not work correctly!
 
echo makepagenav($_GET['rowstart'], $items_per_page, $rows, 3, FUSION_SELF."?this=that&amp;", "rowstart");
 
// Here comes some other code
// and then the second makepagenav
// in this example we use the code frorm the comments' nav
 
echo makepagenav($_GET['c_start'], $cpp, $c_rows, 3, $clink."&amp;", "c_start");
?>

This is an example for pages where you have to use more than one pagination. With the last parameter you can specify which $_GET variable would you use for the current item's pagination.

Changelog
7.02.00 - Added $getname parameter
7.01.00 - Fixes mentioned in this thread
7.00.00 - Output as <div> not a <table>


See also …


References