New to programming and looking for help please,
i need to the set the value of $b_num based on the value of $egg_type i have tried using an if statement but not having any luck
`
$egg_type = $row["egg_type"] ;
if ($egg_type == 'M/S Select Farm')
{
$b_num = '1';
}
if ($egg_type = 'Free Range')
{
$b_num = '1';
}
if ($egg_type = 'Barn')
{
$b_num = '2';
}
if ($egg_type =='Intensive')
{
$b_num = '3';
}
if ($egg_type == 'Organic')
{
$b_num = '0';
}
if ($egg_type == 'Brioche')
{
$b_num = '3';
}
`
Tried the if statement but the value didnt change,
2
Answers
First you’ve to check if your $egg_type variable is being set in order not to make errors later
Second you can do it like this
Maybe
$egg_type
is null value. Therefore,you can improve your code (PHP 8.0 version) and set default value for b_num like this: