使用$ _GET变量

I need a little help with using $_GET variables if possible. Right now I am using them to load different parts of my website when needed but I can't figure out how to clear the screen as if a new page were being loaded when the $_GET variable is set. I was wondering if it is possibele.

As an example say I have a sports categories page which lists all the sport available on the website, In the controller I have this piece of code which activates when the user clicks on football in the list of sports:

if (isset($_GET['football'])) 
        {  
            .... 
        }

So at the moment all of the football information is displayed along with all of the category information. Is there a way to remove the category information and just have the sports info there without using javascript?

Any pointers in the right direction would be really appreciated.

Thank You

Assuming that when the user clicks "Football" a new HTTP request is done, then you can have:

if(!isset($_GET["football"])) ... { // Code to display categories }

If you don't have another HTTP request, then you will have to do it with Javascript, hidding the element that contains the category list.

Hope this helps...

I think what you are looking for is an else statement. Or otherwise, you need to write your code in such a way that categories are only displayed if $_GET['football'] is not set.

The $_GET method is usually used to retrieve variables from a webpage's URL. Although it could be populated in other ways i believe. To clean it just unset it. Like so:

unset($_GET["football"]);

Also, if you are using it to retrieve data from you URL you can just refresh the page without the variables on it like so Original URL: www.stackoverflow.com?id=10 Refresh it as empty www.stackoverflow.com

With those 2 methods, you should be able to clear your gets from any data. Use accordingly to your situation.

Instead of using the querystring key to differentiate, use a common key (in my example category ) and change the value, eg http://example.com/page.php?category=football.

Then you can perform a switch on the value, and show either the category content, or the list of categories if no specific category is requested:

$category = isset($_GET['category']) ? $_GET['category'] : 'none';

switch($castegory){
    case 'football':
        //show football content
        break;
    case 'golf':
        //show golf content
        break;
    default:
       //show list of categories
}