複製代碼 代碼如下:
$price=$row['price']; //原價
$nowprice=$row['nowprice']; //現價
$jiesheng=$price-$nowprice; //節省金額
//$discount折扣計算
if ( $nowprice > 0 )
{
$discount = round(10 / ($price / $nowprice), 1);
}
else
{
$discount = 0;
}
if ( $discount <= 0 ) $discount = 0;
完整代碼:
複製代碼 代碼如下:
徐州汽車網最新團購
error_reporting(0);
header("Content-type: text/html; charset=gbk");
$con = mysql_connect("localhost","mysql使用者名稱","mysql密碼");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// some code
mysql_select_db("tuanpcqc");
mysql_query("set names gbk");
$sql="select * from cenwor_tttuangou_product order by id desc limit 0,3";
$result = mysql_query($sql);
?>
while($row = mysql_fetch_array($result, MYSQL_BOTH)) {
$id=$row['id'];
$name = $row['name'];
$price = $row['price'];
$price=$row['price'];
$nowprice=$row['nowprice'];
$jiesheng=$price-$nowprice;
if ( $nowprice > 0 )
{
$discount = round(10 / ($price / $nowprice), 1);
}
else
{
$discount = 0;
}
if ( $discount <= 0 ) $discount = 0;
$pic=$row['img'];
$pic_arr=split(",",$pic);
$picadd=$pic_arr[0];
//echo $picadd;
$sql2="select * from cenwor_tttuangou_uploads whereurl");
$picurl=str_replace("/demo/","/thumb/200x121/demo/",$picurl);
?>
- " target="_blank">" width="120" height="90" />
- ¥" target="_blank">
-
}
?>
function getpic($pic){
}
mysql_close($con);
?>
以上就介紹了利息保障倍數計算公式 php 團購折扣計算公式,包括了利息保障倍數計算公式方面的內容,希望對PHP教程有興趣的朋友有所協助。