我从DB收到价值
$row['jackpot']
它等于5000.00
如何写出正确的条件?
if ($row['jackpot'] < '2000.00') {
$asd = "2000.00" - $row['jackpot'];
echo "To participate you are missing".$asd;
}
答案 0 :(得分:0)
jackpot
列的数据类型是什么?如果它是字符串,那么你需要使它浮动,只有<
运算符才能在if statement
中运行。
$row_jackpot = (float)$row['jackpot'];
if ($row_jackpot < 2000.00) {
$asd = 2000.00 - $row_jackpot;
echo "To participate you are missing".$asd;
}
答案 1 :(得分:0)
如果要保留两位小数,请使用$jackpot = (float)$row['jackpot'];
if ($jackpot < 2000) {
$asd = number_format(2000 - $jackpot, 2);
echo "To participate you are missing".$asd;
}
pass
答案 2 :(得分:0)
假设您的$row['jackpot'] = 1000.00;
然后试试这个
if ($row['jackpot'] < 2000.00) {
$asd = number_format(2000.00 - $row['jackpot'], 2);
echo "To participate you are missing " . $asd;
}