Transactions

icon picker
Diamond Calculations

public static function diamondCalc($size, $colour, $clarity, $count) {
global $db;
$pricing = array('poor'=>'price_1',
'good'=>'price_2',
'excellent'=>'price_3');
$sql = "SELECT *
FROM gold_diamond
WHERE size_min <= ?
AND size_max >= ?";
$params = array("dd",$size,$size);
$res = $db->cleanQueryArr($sql,$params);
if($db->getLastnumrows() > 0) {
$price = 0.00;
foreach($res as $row) {
if($row['price_type'] == 'colour') {
$price = $price + $row[$pricing[$colour]];
} elseif($row['price_type'] == 'clarity') {
$price = $price + $row[$pricing[$clarity]];
}
}
$price = number_format($price * $count, 2, '.', '');
return $price;
} else {
return 0.00;
}
}
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.