Copy CodeThe code is as follows:
$price = $row [' Price ']; Price
$nowprice = $row [' Nowprice ']; Current
$jiesheng = $price-$nowprice; Save money
$discount Discount Calculation
if ($nowprice > 0)
{
$discount = Round ($price/$nowprice), 1);
}
Else
{
$discount = 0;
}
if ($discount <= 0) $discount = 0;
Full code:
Copy CodeThe code is as follows:
<title>Xuzhou Auto Network New purchase</title>
error_reporting (0);
Header ("content-type:text/html; CHARSET=GBK ");
$con = mysql_connect ("localhost", "MySQL User name", "MySQL password");
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 ($price/$nowprice), 1);
}
Else
{
$discount = 0;
}
if ($discount <= 0) $discount = 0;
$pic = $row [' img '];
$pic _arr=split (",", $pic);
$picadd = $pic _arr[0];
Echo $picadd;
$sql 2= "SELECT * from Cenwor_tttuangou_uploads where id=". Intval ($picadd);
$result 2 = mysql_query ($sql 2);
$picurl = Mysql_result ($result 2, 0, "url");
$picurl =str_replace ("/demo/", "/thumb/200x121/demo/", $picurl);
?>
- "target=" _blank ">" width= "height="/> "
- ¥ "target=" _blank ">
Price |
Discount |
Save |
|
Fold |
¥ |
}
?>
function Getpic ($pic) {
}
Mysql_close ($con);
?>
http://www.bkjia.com/PHPjc/324539.html www.bkjia.com true http://www.bkjia.com/PHPjc/324539.html techarticle Copy the code as follows: $price = $row [' price '];//The original value $nowprice = $row [' Nowprice '];//Pay $jiesheng = $price-$nowprice;//Save money//$ Discount Discount calculation if ($nowprice 0) ...