I'm a noob, and I'm following a guide to setup counts, page numbers, and links for the additional pages that follow a SQL LIMIT query.
So far, everything works. I have total counts, total page numbers, and linkable pages. It looks like this and appears to be accurate:
The problem lies with actually linking to the next pages. The links fail to make the page go to the next page and I either get errors, or simply the default query reloads page 1. I can never get to page 2.
The section of his page I'm stuck at is titled "Linking To Other Pages". He uses these 3 different lines to make the pages link:
<a href=\"$PHP_SELF?query=$query&page=$back_page&limit=$limit\">back</a>
<a href=\"$PHP_SELF?query=$query&page=$ppage&limit=$limit\">$i</a>
<a href=\"$PHP_SELF?query=$query&page=$next_page&limit=$limit\">next</a>
Regardless of what I try, I can't get that code to actually link the page. $query is not defined in my code, and I can't really see where it's defined in his, so I don't know how to properly formulate my structure. I could really use some help.
More Info About My Code:
Some variables from my code (the query is an example as it's actually much longer):
$database = new mysqli($hostname, $username, $password, $databasename);
$sqlquery = "SELECT DISTINCT";
$sql = "
event.event_id as 'Event ID',
event.event_group_id as 'Group ID',
abs_path.abs_path as 'Path\Filename'
FROM
event.event_group
LEFT JOIN event.event using (event_group_id)
LEFT JOIN event.package_config using (event_id)
LEFT JOIN file_info.abs_path using (abs_path_id)
WHERE event.timestamp >= DATE_SUB(CURDATE(),INTERVAL $time)
LIMIT 50";
$result = $database->query($sqlquery.$sql);
If I try to replace his ?query=$query variable with variations of my $sqlquery$sql variables like this:
<a href=\"$PHP_SELF?query=$sqlquery$sql&page=$back_page&limit=$limit\">back</a>
Then it causes this to happen in the browser (of course I don't get proper results with this):
The only other difference I see between his code and mine is his code shows this:
while ($data = mysql_fetch_array($results))
Whereas I do this:
while($row = $result->fetch_row())
I'm not calling 'array'. But from my research, I'm not sure this is my issue (it's just the only other thing that is different, so I figured I'd mention it just in case)
I just can't get the query to _POST and I have no idea what I'm doing wrong. I'm really frustrated. Can anyone possible help out? I can provide more info if needed.
Thanks.