Re: Paging Help
| From: | Juanjo Pascual | Date: | Tue, 20 Jun 2006 16:22:52 +0000 |
| Subject: | Re: Paging Help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238413@lists.php.net to get a copy of this message | ||
<?php
// Num of records each time
$NUM_RECORDS = 10;
if ($_GET["pag"] == "") {
$ini = 0;
$pag = 1;
}
else {
$ini = ($pag - 1) * $NUM_RECORDS;
}
// Query to show
$query_rsData = "SELECT * FROM table LIMIT " . $ini . ", " . $NUM_RECORDS;
$rsData = mysql_query($query_rsData, $DB_CONECTION);
// Total records
$query_rsData2 = "SELECT * FROM table";
$rsData2 = mysql_query($query_rsData2, $DB_CONECTION);
$num_total_records = mysql_num_rows($rsData2);
// Total pages
$total_pag = ceil($num_total_records / $NUM_RECORDS);
$previous_page = $pag - 1;
$next_page = $pag + 1;
?>
Links for the pages
-------------------
First page: this_page.php?pag=1
Previous page: this_page?pag=<?php echo previous_page; ?>
Next page: this_page?pag=<?php echo next_page; ?>
Last page: this_page?pag=<?php echo total_pag; ?>
Rodrigo de Oliveira Costa escribió:
I have the following problem, I need to make a paging system to showresults from search on a Mysql database. I found a class thatshould do the job but couldn't figure it out how to use it. Does anybody has an Idea of hos to do this? I thank in advance for any help you guys can provide me. Rodrigo