Thanks for the replies everyone. I'm having a tough time figuring out how to pass my page number through the URL. I'm not sure what variable contains that value. (I got the pagination script from a book). At the top of my document I have the script that sets up the values thusly:
Code:
$display = 3;
if (isset($_GET['p']) && is_numeric($_GET['p'])) {
$pages = $_GET['p'];
} else {
$q = "SELECT COUNT(id) FROM links_clicked";
$r = mysql_query($q, $db);
$row = mysql_fetch_array($r, MYSQL_NUM);
$records = $row[0];
$_SESSION['records'] = $records;
if ($records > $display) {
$pages = ceil($records/$display);
} else {
$pages = 1;
}
}
if (isset($_GET['s']) && is_numeric($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
Then lower down are the links that control the pagination itself:
Code:
if ($pages > 1) {
$current_page = ($start/$display) + 1;
}
if ($current_page != 1) {
echo '<li><a href="clicks.php?s=' . ($start - $display) . '&p=' . $pages . '">« prev</a></li>';
}
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo '<li><a href="clicks.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a></li>';
} else {
echo '<li class="current">' . $i . '</li>';
}
} // end of for loop
if ($current_page != $pages) {
echo '<li><a href="clicks.php?s=' . ($start + $display) . '&p=' . $pages . '">next »</a></li>';
}
My sql query is:
Code:
$sql = "SELECT first_name, last_name, email, page, link_name, DATE_FORMAT(date_clicked, '%m/%d/%Y') AS Date
FROM links_clicked
ORDER BY $order[$o]
LIMIT $start, $display";
Is $start the variable that contains the current page?
Bookmarks