I was wondering how am i able to do that?

i have inline-block div of images, how am I supposed to divide it.. like 10 images per page?

i am using php here btw so it has loops.

i don't know if i am posting in the right place but my instincts says so.

i can provide the code if need be.

THANKS!

Dani AI

Generated

Nice question, — and good callout by (that term is "pagination"). A compact, practical plan:

Read the page number from GET, validate/cast it to an integer, set perPage = 10, compute offset = (page - 1) * perPage, then fetch only that slice of images. For a database use LIMIT :perPage OFFSET :offset with prepared statements; for an in-memory array use array_slice. Always clamp the page to a minimum of 1 and guard against negative/overflow offsets.

$perPage = 10;
$page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT) ?: 1;
$page = max(1, (int)$page);
$offset = ($page - 1) * $perPage;

// DB: SELECT ... ORDER BY ... LIMIT :perPage OFFSET :offset (use prepared statements)
// OR: $pageImages = array_slice($allImages, $offset, $perPage);

For layout: inline-block can cause gaps and uneven wrapping; prefer CSS Grid or Flexbox for stable rows. If using inline-block, removing inline whitespace (container font-size:0) or using fixed item sizes plus box-sizing: border-box and object-fit: cover on images will prevent row jumps when paginating. See the MDN docs on display for layout behavior. (developer.mozilla.org)

Add usable navigation (prev/next, page numbers), show totals (SQL SELECT COUNT(*) then ceil(total / perPage)), preserve filters in the query string, and lazy-load thumbnails (loading="lazy" or an IntersectionObserver) to keep performance smooth. For PHP array pagination, array_slice is the built-in helper. (php.net)

Recommended Answers

All 2 Replies

What you're referring to is called pagination.

If you google php pagination tutorials you'll find plenty.

oh oh thanks for that term! I will try it then come back for results!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.