Jump to content

Best Way to Remember the Last Pressed Submit Button Condition?


chaseman

Recommended Posts

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