Skip to main content
April 6, 2010
Answered

Question for David Powers about displaying of a subset of records

  • April 6, 2010
  • 1 reply
  • 1691 views

David,

I have used your fantastic book, PHP Solutions to great success in developing my own projects.

My problem is in following your approach for displaying a subset of records from my database. In your book (page 333, php solution 12-4), you use tables, and in my design I am using CSS. Everything works great if I display the entire record set, but when I want to limit the number of records shown on a page, I can't make it work. I'm suspecting that your method using the table was 'self-governing' to the extent that the table was created based on the various parameters of the subset.

I'm not looking for a line-by-line code example, rather I would like to find a resource that might help me shed light on this problem. I have been trying things for hours today, but can not acheive my goal of limiting x-amount of subsets per page.

Any nudge in the right direction would be greatly appreciated.

Sincerely,

wordman

This topic has been closed for replies.
Correct answer David_Powers

The fact that the thumbnails are displayed in a table is irrelevant. What controls the subset of records being retrieved from the database is the code in step 4 at the top of page 335.

$startRow is the current page number (counted from 0) times SHOWMAX (the number of elements you want to show on the page.

That results in the SQL on page 2 being this: "SELECT * FROM images LIMIT 6, 6". ($startRow is 1 * 6).

1 reply

David_Powers
David_PowersCorrect answer
Inspiring
April 7, 2010

The fact that the thumbnails are displayed in a table is irrelevant. What controls the subset of records being retrieved from the database is the code in step 4 at the top of page 335.

$startRow is the current page number (counted from 0) times SHOWMAX (the number of elements you want to show on the page.

That results in the SQL on page 2 being this: "SELECT * FROM images LIMIT 6, 6". ($startRow is 1 * 6).

April 7, 2010

David,

Many thanks for the insight. It helped me understand the problem, which was actually related to some additional query logic I am using.

However, my main hurdle still lies in front of me.

I'll post this in a new thread.

Thank you so much!

Sincerely,

wordman