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: 
I would first check if $\_GET["loanprovider"] is set because if you don't set loanprovider in the url it will be undefined and undefined does not have to be "0" it can be something else. In this case it would be probably some value that makes your statement ((int)$\_GET["loanprovider"] > 1): true.

The correct code would be:

```
if (isset((int)$_GET["loanprovider"]))
{
  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;
  }
}  

```
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;

```