i need to develop page to show the data in multiple pages.page numbers should be shown at the bottom. on click on page no. the website will show data of that page like google search.probably it is called penigation.

Dani AI

Generated

As described (Google-style numbered links at the bottom), the feature is called pagination. Server-side pagination with PHP + SQL is the usual approach for non-trivial datasets: pick a page size, read a sanitized page index from GET, compute an OFFSET, run a COUNT(*) to know total pages, then SELECT the rows with LIMIT/OFFSET and render the page links.

Example (minimal, using PDO):

<?php
// $pdo = new PDO(..., [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);

$perPage = 10;
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
if ($page < 1) $page = 1;
$offset = ($page - 1) * $perPage;

// total rows (apply same WHERE filters here as in the SELECT)
$total = (int) $pdo->query('SELECT COUNT(*) FROM items')->fetchColumn();
$totalPages = max(1, (int) ceil($total / $perPage));

// fetch page
$stmt = $pdo->prepare('SELECT id, title FROM items ORDER BY created_at DESC LIMIT :limit OFFSET :offset');
$stmt->bindValue(':limit', $perPage, PDO::PARAM_INT);
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

// render simple pager
for ($p = 1; $p <= $totalPages; $p++) {
    if ($p === $page) {
        echo "<strong>$p</strong> ";
    } else {
        echo '<a href="?page=' . $p . '">' . $p . '</a> ';
    }
}

Notes and pitfalls: always cast and clamp the page parameter to an integer; bind LIMIT/OFFSET as integers to avoid injection; ensure the COUNT(*) uses the same filters as the SELECT so page numbers match results. For very large tables, OFFSET queries get slow — consider keyset pagination (WHERE id < last_id LIMIT N) or caching row counts. For UX, show Prev/Next and a truncated range (e.g., current +/- 3 pages with first/last links) so hundreds of page links are not printed. As already noted, tutorials exist for this pattern, but the snippet above shows the core implementation points.

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.