Jump to content

view all plus pagination?


samoht

Recommended Posts

hello again,

 

i have a online store that has about 2800+ products  - on my productList.php pages I have a few variables to display the number of products per page:

<?php
$productsPerRow = 3;
$productsPerPage = 27;

my boss would like a view all button that sets $productsPerPage to the total number of products  - and is active for as long as the SESSION (Perhaps unless the button is clicked again?)

 

Any Ideas on the best approach to accomplish this??

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/70637-view-all-plus-pagination/
Share on other sites

I'd assume your query is like

<?php
$q = "Select Fields from `table Where This=that";
$q .= " Limit ".$stat." , ".$end;
?>

If that is the case and you want to have a bool var saying pagination on/off just add some if logic like

 

<?php
$q = "Select Fields from `table Where This=that";
if($pagination == 1){
$q .= " Limit ".$stat." , ".$end;
}
?>

and you set $pagination based on a variable sent by the user via get or how ever you like.

 

Do the same on all other elements that are pagination.

 

This is also assuming your output is generated in a

while($row = mysql_fetch_array($r)){

 

sort of fashion

so then just a button?

<input type="button" id="viewall" name="viewall" value="View All">

 

then

<?php
$pagging = isset($_GET['viewall'])
if($pagging == 1){
$result     = dbQuery(getPagingQuery($sql, $productsPerPage));
$pagingLink = getPagingLink($sql, $productsPerPage, "g=$cgId&c=$catId");
}else{
$result = dbQuery($sql);
}
[code]

[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.