Re: [PHP-DB] LIMITiT

2008-05-20 Thread James
>   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



[PHP-DB] LIMITiT

2008-05-20 Thread elk dolk
  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);