Is there a more consolidated way to code this other than doing this 600 times lol? if ($row['experience'] >= 0 <= 19) { $level = 1; } else { if ($row['experience'] >= 20 <= 39) { $level = 2; } else { if ($row['experience'] >= 40 <= 59) { $level = 3; } else { } } } Code (markup):
if ($row['experience'] >= 0 <= 19) { $level = 1; } else if ($row['experience'] >= 20 <= 39) { $level = 2; } else if ($row['experience'] >= 40 <= 59) { $level = 3; } else { } PHP: or switch($row['experience']): case ($row['experience'] >= 0 AND $row['experience'] <= 19): $level = 1; break; case ($row['experience'] >= 20 AND $row['experience'] <= 39): $level = 2; break; case ($row['experience'] >= 40 AND $row['experience'] <= 59): $level = 3; break; default: endswitch; PHP:
He doesn't mean that I think^ You can put everything in a Array and do a for loop. Not sure if this works, but try something like this; $a = array('0', '20', '40', '60'); $lvl = 0; for($i=0;$i<count($a);$i++){ if($i+1 == count($a) && $lvl==0){ $lvl = $i; }else{ if($row['experience'] >= $a[$i] && $row['experience'] <= $a[$i+1]){ $lvl = $i; } } } PHP: