ben sana çalışan ve kolay bir pagination örneği vereyim, ona göre düzenlersin, zaten oldukça da basittir.
<?php
$user_db = 'root'; // Server Username
$pass_db = ''; // Server Password
$host_db = 'localhost'; //Server (e.g. localhost)
$db = 'database'; // Database Name
@mysql_connect ($host_db, $user_db, $pass_db);
@mysql_select_db ($db);
$table = 'table'; // The name of your table in the database
$limit = '10'; // How many results should be shown at a time
$scroll = '1'; // Do you want the scroll function to be on (1 = YES, 2 = NO)
$scrollnumber = '10'; // How many elements to the record bar are shown at a time when the scroll function is on
// Get the total number of rows in a database
$query1 = mysql_query ("SELECT * FROM $table");
$numrows = mysql_num_rows ($query1);
//
if (!isset ($_GET['show'])) {
$display = 1;
} else {
$display = $_GET['show'];
}
// Return results from START to LIMIT
$start = (($display * $limit) - $limit);
$query2 = mysql_query ("SELECT * FROM $table LIMIT $start,$limit"); // Add ORDER BY field ASC or DESC to order the results
while ($myrow = mysql_fetch_array ($query2)) {
?>
<p>YOUR RESULT: <?= $myrow['ROW']; ?></p>
<?php
}
//
$paging = ceil ($numrows / $limit);
// Display the navigation
if ($display > 1) {
$previous = $display - 1;
?>
<a href="<?= $_SERVER['PHP_SELF']; ?>?show=1"><< First</a> |
<a href="<?= $_SERVER['PHP_SELF'] ?>?show=<?= $previous; ?>">< Previous</a> |
<?php
}
if ($numrows != $limit) {
if ($scroll == 1) {
if ($paging > $scrollnumber) {
$first = $display;
$last = ($scrollnumber - 1) + $display;
}
} else {
$first = 1;
$last = $paging;
}
if ($last > $paging ) {
$first = $paging - ($scrollnumber - 1);
$last = $paging;
}
for ($i = $first;$i <= $last;$i++){
if ($display == $i) {
?>
[ <b><?= $i ?></b> ]
<?php
} else {
?>
[ <a href="<?= $_SERVER['PHP_SELF']; ?>?show=<?= $i; ?>"><?= $i; ?></a> ]
<?php
}
}
}
if ($display < $paging) {
$next = $display + 1;
?>
| <a href="<?= $_SERVER['PHP_SELF']; ?>?show=<?= $next; ?>">Next ></a> |
<a href="<?= $_SERVER['PHP_SELF']; ?>?show=<?= $paging; ?>">Last >></a>
<?php
}
//
?>