If category selector is set via HTTP request, than forget about method 1. If it is set over POST request that the second one will do. If via GET request - both methods will not work.
Calling an URL like domain.com/test_gallery.php?cat=1 is a GET HTTP request and the code will be like this:
if (isset($_GET['cat])) {
include whatever you should
} else {
echo 'an error';
}
Anyway, regarding your second example - it is impossible for a variable to be set and unset in the same time. In the case of $_POST request - the second example will work.

Also, turn on all errors in PHP - you'll got pleanty of notices about your code and line numbers with descriptions of possible problems.