There are some issues in the Pagination section pages 55-56.
I used the code in the book. Once I cleared up these issues
the pagination worked. I had a previous post on the testing
scripts I used.
ISSUE #1
The book has
Code:
mysql_data_seek($start);
This is not correct; it takes 2 arguments. It should be
Code:
mysql_data_seek($result,$start);
($result is from mysql_query)
The download code is correct
ISSUE # 2
The book has
Code:
while( $row = mysql_fetch_assoc($result) && $count++ < $display)
This is not correct. There needs to be parenthesis around
the $row = mysql_fetch_assoc($result)
It should be
Code:
while( ($row = mysql_fetch_assoc($result)) && $count++ < $display)
The download code changed it to put $count++ < $display in front. that is
Code:
while ($count++ < 25 && $row = mysql_fetch_array($result))
Now, I would rather not have the 25 hard coded like this. I would
rather have a $display variable like they do in the book.
ISSUE # 3
Spelling error. Both the book and download code have it wrong
Code:
// Generate the paginiation menu
Should be
Code:
// Generate the pagination menu
ISSUE # 4
In the book it has $form_id instead of $forum_id
This happens in two places.
It is in the //Generate the pagination section
Code:
echo '<a href="view.php?fid=' . $form_id . '&start=0">' .
'FIRST</a>   ';
It should be
Code:
echo '<a href="view.php?fid=' . $forum_id . '&start=0">' .
'FIRST</a>   ';
and the second place is
Code:
echo '<a href="view.php?fid=' . $form_id . '&start=' .
($total - $display) . '">LAST</a> ';
It should be
Code:
echo '<a href="view.php?fid=' . $forum_id . '&start=' .
($total - $display) . '">LAST</a>';
The download code is a little different. It leaves out FIRST and LAST.
It does have it spelled correctly.
ISSUE # 5
The pagination menu needs more space between the links. Currently
they are crammed together.
I solved it by adding    after the </a>
Code:
echo '<a href="view.php?fid=' . $forum_id . '&start=0">' .
'FIRST</a>   ';
echo '<a href="view.php?fid=' . $forum_id . '&start=' .
($start - $display) . '"><PREV</a>   ';
}
if ($total > ($start + $display))
{
echo '<a href="view.php?fid=' . $forum_id . '&start=' .
($start + $display) . '">NEXT></a>   ' ;
echo '<a href="view.php?fid=' . $forum_id . '&start=' .
($total - $display) . '">LAST</a> ';
ISSUE # 6
The book shows us how to implement this pagination for the messages.
It does not implement pagination for number of forums or replies.
I guess that's reasonable, they showed us how to do it, and we can
implement it on our own for forums and replies.
ISSUE # 7
The book uses FIRST PREV NEXT LAST whereas the download code uses
just PREV NEXT
It seems having the FIRST PREV NEXT LAST is preferable because you can get to the beginning or end quickly.
__________
Like I say, after I fixed these issues the pagination was working for me.