Copy Code code 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;
Complete code:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Xuzhou Auto Network latest group buy </title>
<style type= "Text/css" >
body{margin:0 auto; Text-align:center padding:0}
ul,li{margin:0; Padding:0;list-style:none}
body,td,th {
font-size:12px;
}
a:link {
Color: #333333;
Text-decoration:none;
}
a:visited {
Text-decoration:none;
Color: #333333;
}
a:hover {
Text-decoration:none;
Color: #FF3300;
}
a:active {
Text-decoration:none;
}
img{border:0;}
/*group buy*/
. groupbuy{width:970px; border:1px solid #FEDDBA; padding:4px;
. groupbuy ul{width:146px; border:1px solid #FEDDBA; padding:2px; height:180px; float:left; margin:0 4px;}
. groupbuy ul li{Text-align:center;}
. groupbuy ul li.realprice{background: #333; Background:url (... /images/groupprice.jpg) No-repeat right top; height:40px; line-height:40px; font-family: "Microsoft Yahei", Arial;display:block; Font-weight:bold;color: #fff;}
. groupbuy ul Li.realprice img{cursor:pointer;
. groupbuy ul Li.realprice span{float:left; margin:0; padding:0}
. groupbuy ul Li.realprice span b{font-size:18px;}
. groupbuy ul li.supprice{Text-align:center;}
. groupbuy ul li.supprice div table td{background: #FDF4E3; text-align:center;}
</style>
<body>
<?php
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);
?>
<div class= "Groupbuy Clear" >
<?php
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);
?>
<ul>
<li><a href= "http://tuan.pcqc.com.cn/?view=<?= $id?>" target= _blank "> "width=" height= "/></a></li>"
<li class= "Realprice" ><span>¥<b><?= $nowprice? ></b></span><a href= "http:// tuan.pcqc.com.cn/?view=<?= $id?> "target=" _blank "></a> </li>
<li class= "Supprice" >
<div>
<table>
<tr>
<td> Original Price </td>
<td> Discounts </td>
<td> Savings </td>
</tr>
<tr>
<td><?= $price?></td>
<td><?= $discount?> Folding </td>
<td>¥<?= $jiesheng?></td>
</tr>
</table>
</div>
</li>
</ul>
<?php
}
?>
</div>
<?php
function Getpic ($pic) {
}
Mysql_close ($con);
?>
</body>