Jump to content

Hot to allow user to change what category a query is run on?


Recommended Posts

Hi

I am trying to change something with the following query, but I have no idea how to go about it.

 

Currently my query takes a variable from a preset setting:

$catid = trim( $params->get( 'catid' ) );

 

And then runs a query in a script, and displays the results.

 

However, what I am trying to do, is that instead of pulling the information in from a preset setting, I want the end user to be able to choose what category they want to display results from.

 

So....

 

I am trying to get it that it should check a cookie to see if the user has a already chosen a category, if yes it will display the results of from that category, and give the user a choice to switch but if not, it should just say that you can choose which category, you want.

 

All that should be simple, and I think I know how to create the cookie and check for a cookie. But I dont know how to take the results of the cookie and stick it into the parameter AND then to refresh. And to make it that the variable that is inputed (ex: 45) is displayed as a text choice (ex: Homes)

 

Also, Is there a way I can make it, that instead of a regular drop down box, to choose your category, there is a button that creates a nice pop up (but without it being a pop up window) allowing you to choose.

 

Also, Is there a way to make it, that if they choose or make a change, the entire page doesn't need to reload, only this particular section?

 

I know this is a long question, but any help will be most appreciated.

Thank you

 

Here is how I think to handle the cookie information:

if(isset($_GET['category'])){
$category = $_GET['category'];
setcookie('category', $category);
} elseif(isset($_COOKIE['category'])){
$category = $_COOKIE['category'];
} else{
setcookie('category', '45');
$category = "category";
}

All that should be simple, and I think I know how to create the cookie and check for a cookie. But I dont know how to take the results of the cookie and stick it into the parameter AND then to refresh. And to make it that the variable that is inputed (ex: 45) is displayed as a text choice (ex: Homes)

 

I figured some of this out, but I  still dont know how to get it to refresh on the fly.

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.