Actually i have 8 semester . so i have to do it in nested if statement. bcoz i want to checked whether previous sem fees has paid or not. But problem is that some courses have direct admission to third or fourth sem.
I think there is not shortcut for saving 8 if-else for this situation.
To check previous semester fees you can save previous semester column name in students table and check against this column name either in 8 if-else
OR
as follows,
Here $fee_col_name is one of the (First_sem_paid_fees,Second_sem_paid_fees,Third_sem_paid_fees,…).
$fee_col_name = $student->earlier_sem_colname;
if(empty($fee_col_name))
{
// No earlier semester
// This is first semester
}else
{
// check earlier sem fees here
if($student->$fee_col_name>0)
{
}
}
This is just a work around, I dont think it is ideal way, let see if others share their solution.