Here’s the loop and code:
$rev_sel = 0.01;
for($i=1.00; $i>=0; $i=$i-.01) {
$val = $i;
$val2 = $val * 100;
echo "<option value='".$i."'";
if($i == $rev_sel) echo "selected='selected'";
echo ">".$val2."%</option>";
}
As far as I can tell, this should end up with the 1% being selected when it pops up, or whatever $rev_sel is set to between 0 and 1.00. It isn’t the case. Anybody know why?
You do need to round like so:
Your code was outputting:
0.00999999… etc is not equal to 0.01