Finding the results of a value-filled

Source: Internet
Author: User
To find a fill value effect
This post was last edited by lazygc520 on 2013-06-28 17:35:24

The picture is as follows:


The effect that can be achieved, such as when the total quantity is 240, the first cell of the purple is 120, and the second cell is 240-120=120.
The diagram has the following relationship:

A stockno corresponds to multiple rows, and two rows in the figure. If a page corresponds to more than one stockno, the total count of $arrs corresponds to the count value assigned to the first Stockno, and the remaining value is assigned to the value in the next stockno corresponding purple box.

The code shown is as follows:

$sql = "Select DISTINCT b.packageno,a.stock_no from ' Stock_detail ' as a, ' kw_manage ' as B where a.stock_no = '". $stockno [$j -1]. "' and a.cust_no = replace (b.cust_no, ' ', ')";
echo $sql. '
';
$result = mysql_query ($sql);
$res = Array ();
while ($row = Mysql_fetch_array ($result, MYSQL_ASSOC))
{
$sql 2 = "Select Lotno,count (Lotno) from ' vp_barcode_2d_y ' where Packageno = '". $row [' Packageno ']. "' GROUP by Lotno,package No ORDER BY lotno ASC ";
echo $sql 2. '
';
$result 2 = mysql_query ($sql 2);
$var = Array ();
while ($row 2 = mysql_fetch_array ($result 2,mysql_num))
{
if (Isset ($res [$row 2[0]))
$res [$row 2[0]][' count '] + = $row 2[1];
Else
$res [$row 2[0]] = Array (' lotno ' = = $row 2[0], ' count ' = $row 2[1]);
}
}
Ksort ($res);
$arrs = Array ();
foreach ($res as $v 2)
{
$arrs [] = $v 2;
}
Print_r ($arrs);//array ([0] = = Array ([Lotno] = 3207 [count] = 240))


$sql 4 = "Select Arr_time,c_type,cust_no,snp,mount,mount*snp as M_total from". $t. " ' Where Stock_no = '. $stockno [$j-1]. "'";
$result 4 = mysql_query ($sql 4);
$a = array ();
while ($var = mysql_fetch_array ($result 4,mysql_num))
{
$a [] = $var;
}
foreach ($a as $k + $v)//displays two rows of results for a stockno
{
Echo '


'. ($k + 1). '';
?>

echo $v [' 0 '];
?>

echo $v [' 1 '];
?>

echo $v [' 2 '];
?>

$sql = "Select type from ' Kw_info ' where cust_no = '". $v [' 2 ']. "'";
$result = mysql_query ($sql);
$row = Mysql_fetch_array ($result, MYSQL_ASSOC);
echo $row [' type '];
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.