php - elseif echo issue, prints wrong value -
i have problem cant figure out. point of view, should work... database setup 3 different priority values. 0,1,2 0=low, 1= medium, 2=high. following code should able print correct information using if , elseif, reason prints rows "high" priority, in database has 0 or 1.
$pri = $row["prioritet"]; if($pri = 2) { $pri = "<span class='badge badge-danger'>high</span>"; } elseif($pri = 1) { $pri = "<span class='badge badge-warning'>medium</span>"; } elseif($pri = 0) { $pri = "<span class='badge badge-success'>low</span>"; }
the if , elseifs need use comparison operators ('==' or '===', etc). using '=', inadvertently trying assign value 2 $pri, example.
Comments
Post a Comment