LIMITiT

LIMITiT

am 20.05.2008 17:40:41 von elk dolk

--0-447658139-1211298041=:56474
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

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'];
}
$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);





--0-447658139-1211298041=:56474--

Re: LIMITiT

am 20.05.2008 19:59:33 von Bob Lockie

> 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);
>
>
>
>
>



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php