I have a php switch statement and for some reason php switch is only executing the default code in the default block but not in the case block, i check if my variable is isset first, then use switch to select data from my DB, even if i do var_dump($cname); it shows that variable $cname corresponds with my first case, what is the problem here? here is the code
$sel = 1;
$sql = "(select * from insurance_companies WHERE id='$eop' LIMIT $sel)";
foreach ($pdo->query($sql) as $row){
$cID = $row['id'];
$cname = $row['name'];
}
if (isset($cname)) {
switch ($cname) {
case 'CASH':
$query= "SELECT test FROM cash_procedures WHERE test LIKE '%$did%'";
$result= $con->query($query);
break;
default:
$query= "SELECT test FROM procedures WHERE test LIKE '%$did%'";
$result= $con->query($query);
}
}