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

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.