Wrox Programmer Forums
|
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2009, 09:28 PM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default Chap 2 forums, pagination issues page 55-56

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> &nbsp&nbsp';
It should be

Code:
echo '<a href="view.php?fid=' . $forum_id . '&start=0">' .
                  'FIRST</a> &nbsp&nbsp';
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 &nbsp&nbsp after the </a>

Code:
echo '<a href="view.php?fid=' . $forum_id . '&start=0">' .
                 'FIRST</a> &nbsp&nbsp';
      echo '<a href="view.php?fid=' . $forum_id . '&start=' .
                 ($start - $display) . '">&lt;PREV</a> &nbsp&nbsp';
   }
   if ($total > ($start + $display))
   {
      echo '<a href="view.php?fid=' . $forum_id . '&start=' .
                 ($start + $display) . '">NEXT&gt;</a> &nbsp&nbsp' ;
      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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chap 2 forums, testing the pagination section kenj BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 0 October 19th, 2009 08:49 PM
Hyperlink on page 55 rhoss BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 July 6th, 2008 01:12 PM
Access 2003 VBA PG 55-56 KellyR Access VBA 3 June 9th, 2007 08:32 AM
ZVON Tutorial Page 56 id() function scubaduba XSLT 1 November 1st, 2004 12:37 PM
Page 55. Working with 3 projects? BradDotNet BOOK: ASP.NET Website Programming Problem-Design-Solution 1 July 24th, 2003 12:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.