Re: LIMITiT
| From: | James | Date: | Tue, 20 May 2008 17:59:33 +0000 |
| Subject: | Re: LIMITiT | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-44999@lists.php.net to get a copy of this message | ||
> Hi all,
>
> The following code is created by Dreamweaver 8 , it shows 18 records per
> page. I want to limit the total number of records to 54 that means it
> should show only the first 3 pages, but as it is not a simple query I
> can not use LIMIT , it is already used in sprintf.
> Could someone tell me how can I do this?
>
>
> $currentPage = $_SERVER["PHP_SELF"];
>
> $maxRows_showerPagination = 18;
> $MaxPerPage=$maxRows_showerPagination;
>
> $pageNum_showerPagination = 0;
> if (isset($_GET['pageNum_showerPagination'])) {
> $pageNum_showerPagination = $_GET['pageNum_showerPagination'];
> }
Try this:
if ($pageNum_showerPagination > 3) {
$pageNum_showerPagination=1;
}
> $startRow_showerPagination = $pageNum_showerPagination *
> $maxRows_showerPagination;
>
> mysql_select_db($database_DB, $DB);
>
> $query_showerPagination = "SELECT name, cat FROM theTable WHERE number >
> 0 ORDER BY number DESC";
> $query_limit_showerPagination = sprintf("%s LIMIT %d, %d",
> $query_showerPagination, $startRow_showerPagination,
> $maxRows_showerPagination);
> $showerPagination = mysql_query($query_limit_showerPagination, $pager)
> or die(mysql_error());
> $row_showerPagination = mysql_fetch_assoc($showerPagination);
>
>
>
>
>