Page 1 of 1

Paging not working properly

Posted: Thu Jan 23, 2003 10:08 pm
by Leland
I'm having trouble with the paging section of a script that I've used successfully before.
Here's the site:
http://www.lissadesigns.com
Click on the 'Pansy' collection and then try the 'next' or '2' link at the bottom. It shows the correct variables passing through ($start, $num_results, and $num_pages), but it just shows the first 10 items again instead of the next nine that should show. Here's the paging section of the script:

Code: Select all

// Make the links to other pages, if necessary.
if ($num_pages > 1) {
echo '<div align=center>	<p>';

// Determine what page the script is on.	
if ($start == 0) {
$current_page = 1;
} else {
$current_page = ($start/$display_number) + 1;
}

// If it's not the first page, make a Previous button.
if ($start != 0) {
echo '<a href="jewelrycollections.php?start=' . ($start - $display_number) . '&collectionname=' . $collectionname . '&num_pages=' . $num_pages . '&num_results=' . $num_results . ' ">Previous</a> ';
}
// Make all the numbered pages.
for ($i = 1; $i <= $num_pages; $i++) {
$next_start = $start + $display_number;
if ($i != $current_page) { // Don't link the current page.
echo '<a href="jewelrycollections.php?start=' . (($display_number * ($i - 1))) . '&collectionname=' . $collectionname . '&num_pages=' . $num_pages . '&num_results=' . $num_results . ' ">' . $i . '</a> ';
} else {
echo '<b><u> ' . $i . '</b></u>' . ' ';
}
}

// If it's not the last page, make a Next button.
if ($current_page != $num_pages) {
echo '<a href="jewelrycollections.php?start=' . ($start + $display_number) . '&collectionname=' . $collectionname . '&num_results=' . $num_results . '&num_pages=' . $num_pages . ' ">Next</a> ';
}
Any ideas why this isn't working correctly?

Posted: Thu Jan 23, 2003 10:46 pm
by evilcoder
are those items separate entries in a database? if so what databse. Because your code is way to complicated for what you need.

Posted: Fri Jan 24, 2003 2:20 am
by twigletmac
Have you read this because it may have some bearing on the problem:
viewtopic.php?t=511

Mac

fixed it!

Posted: Fri Jan 24, 2003 9:12 am
by Leland
As I was falling asleep last night, the answer came to me:
Unlike previous uses of this paging script, this time I'd written it as a function and put it in an include file--what I'd neglected to do was feed the $start, $num_pages, and $num_results variables into the function along with the collection name variable. Once I did that this morning, all worked perfectly.

Thanks. :D