I have been trying to resolve a problem with pagination in my code. I have a pretty static set of pages, but there are a series of reports that are stored in a database that grows constantly. When a visitor requests to view those reports, pagination is used to limit them at 25 per page. All this works, but a problem with my code on the index page didn't allow for the "&pg25" or whatever to be read. I tried to solve this problem by adding a few lines to my code that checked if there was a "&", splitting it then rebuilding the url so the right page was brought up (confusing, I know... have a look at the code).
Can anyone review the code and tell me where I'm going wrong or what I should do differently? Any help is greatly appreciated.
(The error comes at the line "else $pg = $_GET[($page['trig'])].$page['format'];")
session_start();
$page = Array();
// Edit these vars or leave as is.
$page['home'] = "body"; // Replace this with the default page.
$page['error'] = "404"; // Replace this with the 404 page, can be home.php also or even $page['home'].
$page['format'] = ".php"; // This will be the format of your page so ?page=bla will be bla.php.
$page['trig'] = "page"; // The trigger used so ?page=bla.
// Do not edit below.
if (empty($_GET[($page['trig'])])) $pg = $page['home'].$page['format'];
elseif (!file_exists($_GET[($page['trig'])].$page['format'])) $pg = $page['error'].$page['format'];
elseif ($count(substr_count($_GET[($page['trig'])],"&")) > 0) $build = explode("&", $request, 2);
$pg = $build[0].$page['format']."&".$build[1];
else $pg = $_GET[($page['trig'])].$page['format'];
include("header.php");
include("menu.php");
include($pg);
include("footer.php");