function toltalRetailerComm($userId) {
//print_r ($shoppeId);
$sql = "SELECT shoppe_id FROM atm_super_shoppe WHERE user_id='$userId'";
$query = $this->db->query($sql);
if ($query->num_rows() > 0) {
$result = $query->row();
$shoppeId = $result->shoppe_id;
$sql = "SELECT COALESCE(sum(commission),0) as commission FROM atm_shoppe_commission WHERE shoppe_id ='$shoppeId'";
$query = $this->db->query($sql);
print_r($shoppeId);
if ($query->num_rows > 0) {
$result = $query->row();
$commission = $result->commission;
return $commission;
} else {
Blockquote block2
$sql = "SELECT shoppe_id FROM atm_store WHERE user_id='$userId'";
$query = $this->db->query($sql);
if ($query->num_rows() > 0) {
$result = $query->row();
$storeId = $result->shoppe_id;
$sql = "SELECT COALESCE(sum(commission),0) as commission FROM atm_store_commission WHERE shoppe_id ='$storeId'";
$query = $this->db->query($sql);
print_r($storeId);
if ($query->num_rows > 0) {
$result = $query->row();
$commission = $result->commission;
return $commission;
}
}
}
}
}
I’m new to PHP, can anyone tell me the correct way of using an if/else or elseif in the code shown above? Its not able to go to the second block. Also and can I write a function inside an if/else block?
Are you looking for something like this: