I have the following piece of code that pulls the recordset from the database and I need to sum the total prices on column OrderRepairPrice + OrderOtherPrice + OrderLiftPrice. The piece of code that I have works just fine if all 3 columns contain a numeric value but must of the time all 3 columns doesn't have a value and that's when the code doesn't work. If there's a value on column OrderRepairPrice and the other two are left blank will not give me a total.
<?php
$ord = $GET['ord'];
$urid = $GET['urid'];
$total = 0;
$result = mysql_query("SELECT sum(OrderRepairPrice + OrderOtherPrice + OrderLiftPrice) as total_price FROM Orders WHERE OrderNumber = ". $ord ." AND OrderCustomerID = ". $urid ."");
if ($result && mysql_num_rows($result) > 0) {
$query_data=mysql_fetch_array($result);
$total= (float) $query_data["total_price"];
}
echo $total; ?>