php数组处理
$sql = "SELECT b.lotno as lotno,count(b.lotno) as count FROM `kw_manage` as a inner join `vp_barcode_2d_y` as b on a.packageno = b.packageno where a.cust_no = '".$newstr."' group by lotno order by lotno asc";
$result = mysql_query($sql);
while($var = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo $var['lotno'].' * '.($var['count']).'<br />';
}
$num = 0;
while($var = mysql_fetch_array($result,MYSQL_ASSOC))
{
if($num + $var['count'] <= 100) {
echo $var['lotno'].' * '.($var['count']).'<br />';
$num = $num + $var['count'];
}else {
echo $var['lotno'].' * '.(100 - $num).'<br />';
$num = $num + $var['count'] - 100;
echo $var['lotno'].' * '. $num .'<br />';
}
}