samoht Posted September 25, 2007 Share Posted September 25, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/70637-view-all-plus-pagination/ Share on other sites More sharing options...
cooldude832 Posted September 25, 2007 Share Posted September 25, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/70637-view-all-plus-pagination/#findComment-355000 Share on other sites More sharing options...
samoht Posted September 25, 2007 Author Share Posted September 25, 2007 Thanks for the reply, could you help further with the bool idea? I have a input button <input type="submit" id="viewall" name="viewall" value="View All"> do I need to toggle between 1 and 0 on click? Quote Link to comment https://forums.phpfreaks.com/topic/70637-view-all-plus-pagination/#findComment-355046 Share on other sites More sharing options...
cooldude832 Posted September 25, 2007 Share Posted September 25, 2007 not on click no submit. Quote Link to comment https://forums.phpfreaks.com/topic/70637-view-all-plus-pagination/#findComment-355051 Share on other sites More sharing options...
samoht Posted September 25, 2007 Author Share Posted September 25, 2007 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] Quote Link to comment https://forums.phpfreaks.com/topic/70637-view-all-plus-pagination/#findComment-355055 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.