number_format returns a string. the problem is when it adds a ',' in the number, php doesn't know how to cast it back and handle it as a float.
if you converted 11,250.00 to a float, it drops everything off past the first ',', resulting in 11.
i just made those seperate variables since you are just doing that to print to the screen.
PHP Code:
for ($i=0;$i<30;$i++){
$quantity += $_POST['q'.$i];
}
print "<div class='center-text'><b>Number of Books:</b> ".$quantity."</div>";
for ($i=0;$i<30;$i++){
$fmvtotal += $_POST['fmv'.$i];
}
$fmvtotal_string = number_format($fmvtotal, 2);
print "<div class='center-text'><b>FMV Total $:</b> ".$fmvtotal_string."</div>";
if ($fmvtotal >= 1 && $fmvtotal <= 100) {
$ins = 3.50;
} elseif ($fmvtotal > 100.0) {
$ins = ( ceil( ( $fmvtotal - 100) / 100 ) * 0.45) + 3.50;
} else {
$ins = 0;
}
$ins_string = number_format($ins, 2);
print "<div class='center-text'><b>Insurance Total $:</b> ".$ins_string."</div>";
$servicesubtotal = $_POST['service'] * $quantity;
$servicesubtotal = number_format($servicesubtotal, 2);
print "<div class='center-text'><b>Service Charges $: </b>".$servicesubtotal."</div>";
if ($quantity == 1) {
$shipping = '7.40';
} elseif ($quantity == 2){
$shipping = '10.90';
} elseif ($quantity >= 3 && $_POST['quantity'] <= 5){
$shipping = '14.90';
} elseif ($quantity > 5) {
$shipping = (($quantity-5)*1)+14.90;
} else {
$shipping = 0;
}
$shipping_string = number_format($shipping, 2);
print "<div class='center-text'><b>Shipping Cost:</b> ".$shipping_string."</div><br>";
//grand total calculation
$grandtotal = $shipping+$servicesubtotal+$ins;
$grandtotal = number_format($grandtotal, 2);
print "<div class='center-text'><b>GRAND TOTAL$:</b> ".$grandtotal."</div>";
also, notice you don't need the $_POST[] for every variable. you should really only need to use $_POST[] when retrieving values from a form whos method is set to POST.