phpweb批量更新商品价格!更新某一个分类的商品售价为指定折扣:
代码如下:
define("ROOTPATH", "");
include(ROOTPATH."includes/common.inc.php");
$price = htmlspecialchars( $_POST['price'] );
$isall = htmlspecialchars( $_POST['isall'] );
$catid = htmlspecialchars( $_POST['catid'] );
if($price<1&&!empty($catid)){
if($isall=="on"){
$msql->query( "update {P}_shop_con set price={$price}*price" );
echo "更新全部分类成功!!!! ";
}else{
$msql->query( "update {P}_shop_con set price={$price}*price where catid='".$catid."'" );
echo "更新分类成功!!!! ";
}
}else{
echo "更新失败!!!! ";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"><br />
<html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
<title>phpweb交流平台 <a href="http://www.52phpweb.com">www.52phpweb.com</a> </title><br />
</head>
</p>
<p>
<body><br />
<form id="form1" name="form1" method="post" action="update.php"><br />
<p><br />
<label><br />
折扣<br />
</label><br />
<input type="text" name="price" id="price" />(一折填写0.1,八五折填写0.85;)<br />
</p><br />
<p><br />
<label><br />
分类id<br />
</label><br />
<select id="selcatid" name="catid" ><br />
<?php<br />
$fsql->query( "select * from {P}_shop_cat order by catpath" );<br />
while ( $fsql->next_record( ) )<br />
{<br />
$lpid = $fsql->f( "pid" );<br />
$lcatid = $fsql->f( "catid" );<br />
$cat = $fsql->f( "cat" );<br />
$catpath = $fsql->f( "catpath" );<br />
$lcatpath = explode( ":", $catpath );<br />
$i = 0;<br />
for ( ; $i < sizeof( $lcatpath ) - 2; $i++ )<br />
{<br />
<br />
$tsql->query( "select catid,cat from {P}_shop_cat where catid='{$lcatpath[$i]}'" );<br />
if ( $tsql->next_record( ) )<br />
{<br />
$ncatid = $tsql->f( "cat" );<br />
$ncat = $tsql->f( "cat" );<br />
$ppcat .= $ncat."/";<br />
}<br />
}<br />
if ( $pid == $lcatid )<br />
{<br />
echo "<option value='".$lcatid."' selected>".$ppcat.$cat."</option>";<br />
}<br />
else<br />
{<br />
echo "<option value='".$lcatid."'>".$ppcat.$cat."</option>";<br />
}<br />
$ppcat = "";<br />
}?><br />
</select> <br><br><br><br />
<input type="checkbox" name="isall" id="isall" /><br />
是不是全部分类<br />
</p><br />
<p><br />
<label><br />
<input type="submit" name="button" id="button" value="提交" /><br />
</label><br />
<br><a href='http://www.phpweb96.com'>phpweb交流平台 QQ:2376950812</a> <br />
</p><br />
</form><br />
</body><br />
</html></p>