chaseman Posted February 27, 2011 Share Posted February 27, 2011 The situation: The script is fetching data from the database and printing it out with a while loop, at the same time the rows are being broken up into pages with pagination. The problem: I'm using if and elseif statements for a sorting and ordering functionality. When I now choose a certain category to print out ONLY the chosen category, then the pagination will still be intact. But as soon as I click forward on the pagination navigation links, a page refresh (reload) will happen and the query will default to it's default setting which is category = ALL (and not anymore that specific category I chose earlier). My question: Is there any way to make the script remember the last pressed submit condition? Meaning that if I choose a certain category which should be printed, then the chosen category still remains chosen even if I click the pagination links which cause a page reload? Here's a small script excerpt, to help picture the example: $select_category is taken with $_REQUEST from a drop down menu. // ALL but NO OTHER if (($select_category == 'All') || (!isset($select_category)) && (!isset($most_liked))) { $query = "SELECT * FROM con, user WHERE con.user_id = user.user_id ORDER BY contributed_date DESC"; pagination_start ($dbc, $query); $offset = $pag_array[0]; $rows_per_page = $pag_array[1]; $query = $query . " LIMIT $offset, $rows_per_page"; knuffix_list ($query, $dbc); pagination_end ($pag_array); // CATEGORY but NOT most_liked } elseif (isset($select_category) && !isset($most_liked)) { $query = "SELECT * FROM con, user WHERE con.user_id = user.user_id AND category = '$select_category' ORDER BY contributed_date DESC"; pagination_start ($dbc, $query); $offset = $pag_array[0]; $rows_per_page = $pag_array[1]; $query = $query . " LIMIT $offset, $rows_per_page"; knuffix_list ($query, $dbc); pagination_end ($pag_array); Link to comment https://forums.phpfreaks.com/topic/228982-best-way-to-remember-the-last-pressed-submit-button-condition/ Share on other sites More sharing options...
joshbedo Posted February 27, 2011 Share Posted February 27, 2011 can you post your client side code? Link to comment https://forums.phpfreaks.com/topic/228982-best-way-to-remember-the-last-pressed-submit-button-condition/#findComment-1180227 Share on other sites More sharing options...
chaseman Posted February 27, 2011 Author Share Posted February 27, 2011 What exactly do you want to see? Link to comment https://forums.phpfreaks.com/topic/228982-best-way-to-remember-the-last-pressed-submit-button-condition/#findComment-1180326 Share on other sites More sharing options...
chaseman Posted February 27, 2011 Author Share Posted February 27, 2011 I solved this problem by sending the form over GET instead of POST, the chosen category is now in the URL. Link to comment https://forums.phpfreaks.com/topic/228982-best-way-to-remember-the-last-pressed-submit-button-condition/#findComment-1180349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.