Question: I have the follwing code:

```
switch ((int)$_GET["loanprovider"]) {
    case ((int)$_GET["loanprovider"] > 1):
        $sql_loanprovider1a = " l.id in (select la.loanid from loan_approvals la where la.bankid = ".$_GET["loanprovider"].") and";
        $sql_loanprovider1b = " l.loanid in (select la.loanid from loan_approvals la where la.bankid = ".$_GET["loanprovider"].") and";
        break;
    default:
        break;
}

```

If i run the page without setting LOANPROVIDER in the URL, the SWITCH still enters the first case and not the DEFAULT. How come??

/Bob

Answer: 
The explanation is quite simple:

```
var_dump( (int)$_GET["loanprovider"]  );
var_dump( (int)$_GET["loanprovider"] > 1 );

```

The output is:

```
int(0)
bool(false)

```

They're both the same (the integer 0 (zero) is considered as `FALSE`), and case 1 will always get executed if the query parameter `loanprovider` is empty.

Refer to the [PHP Manual](http://php.net/manual/en/types.comparisons.php) for more information.

---

And, to actually fix the issue, use [`isset()`](http://php.net/isset). It's also a good idea to declare variables and store values if you need to re-use it later.

The following looks neater, in my opinion, and it works (tested):

```
if(isset($_GET['loanprovider'])) 
{
    $value = (int)$_GET["loanprovider"];
    switch ($value) {
        case ($value > 1):
            $sql_loanprovider1a = " l.id in (select la.loanid from loan_approvals la where la.bankid = ".$_GET["loanprovider"].") and";
            $sql_loanprovider1b = " l.loanid in (select la.loanid from loan_approvals la where la.bankid = ".$_GET["loanprovider"].") and";
            break;
        default:
            break;
    }
}

```

For debugging the issue, you can always use [`var_dump`](http://php.net/var_dump).
Not tested but request to try it (though the coding is for >1)

But it will be wrong for negative value.

```
switch (intval($_GET["loanprovider"])) {
    case 0:
        break;
    case 1:
        break;
    default:
        $sql_loanprovider1a = " l.id in (select la.loanid from loan_approvals la where la.bankid = ".$_GET["loanprovider"].") and";
        $sql_loanprovider1b = " l.loanid in (select la.loanid from loan_approvals la where la.bankid = ".$_GET["loanprovider"].") and";
        break;

```