Evaluate the value filling effect

Source: Internet
Author: User
Result: lazygc520 was edited at 17:35:24.

The image is as follows:


For example, when the total number is 240, the first cell in purple is 120, and the second cell is 240-120 = 120.
The relationship in the figure is as follows:

One stockno corresponds to multiple rows, and the figure shows two rows. If a page corresponds to multiple stockno instances, the total number of accounts corresponding to $ arrs removes the count value assigned to the first stockno, the remaining values are assigned to the values in the purple box corresponding to stockno.

The code is as follows:
 '; $ Result = mysql_query ($ SQL); $ res = array (); while ($ row = mysql_fetch_array ($ result, MYSQL_ASSOC) {$ sql2 = "select lotno, count (lotno) from 'VP _ barcode_2d_y 'where packageno = '". $ row ['packageno']. "'group by lotno, packageno order by lotno asc"; // echo $ sql2 .'
'; $ Result2 = mysql_query ($ sql2); $ var = array (); while ($ row2 = mysql_fetch_array ($ result2, MYSQL_NUM )) {if (isset ($ res [$ row2 [0]) $ res [$ row2 [0] ['count'] + = $ row2 [1]; else $ res [$ row2 [0] = array ('lotno' => $ row2 [0], 'count' => $ row2 [1]);} ksort ($ res); $ arrs = array (); foreach ($ res as $ v2) {$ arrs [] = $ v2;} print_r ($ arrs ); // Array ([0] => Array ([lotno] => 3207 [count] => 240) $ sql4 = "select arr_time, c_type, cust_no, snp, mount, mount * snp as m_total from "'. $ t. "'Where stock_no = '". $ stockno [$ j-1]. "'"; $ result4 = mysql_query ($ sql4); $ a = array (); while ($ var = mysql_fetch_array ($ result4, MYSQL_NUM )) {$ a [] = $ var;} foreach ($ a as $ k => $ v) // display the two rows corresponding to a stockno {echo''. ($ K + 1 ).'';?> '; Echo''; // The code to be added; echo''; Echo'   ';}?>


Reply to discussion (solution)

Simple if cannot be solved?

Too many loops and dizzy.

At this time, smarty has shown a powerful side.

Online and other solutions...

Isn't it clear that I have not described it? Why no one returns?

Logical structure:

Stockno corresponds to multiple values in a page, which is the $ stockno [$ j-1] corresponding to the code

When each stockno is the corresponding value, it corresponds to the corresponding row in the database. See 29 lines of code.

The total number of part numbers (cust_no) in the graph in the corresponding row is obtained in line 26 of the code. (1-26 rows to obtain the total number of parts)

Next, we will discuss how to allocate part numbers.

When stockno is the corresponding value, the result corresponding to this value (two rows in the example) is displayed. the number of parts in the two rows is 120 and 135, respectively, corresponding to $ v ['5'] in the 36-line foreach loop of the code (line 79 of the code), the total number of this part number is known to be 240. for details, see line 26th of the code.

Assuming that the total number of parts is 360, enter 120*3207 in the purple box where the number of parts in the figure is 120, enter 135*3207 in the corresponding purple box with a quantity of 135, and the remaining quantity value is added to the next value of stockno. How can this be implemented?

Thank you!

The data you participate in the output is processed separately.
How can we know their relationship?

The data you participate in the output is processed separately.
How can we know their relationship?

The relationship between stockno and cust_no is one-to-one or one-to-many in the 'stock _ detail 'table.

The number of cust_no (part number) is obtained through the inventory table 'kw _ manage', and the total inventory corresponding to this cust_no is obtained.

Then, the number of cust_no (part number) corresponding to stockno is allocated based on the total inventory of the cust_no.

You 'd better paste the test data!

You 'd better paste the test data!
Code 26th lines
Print_r ($ arrs); // obtain the total inventory of the cust_no.

Array ([0] => Array ([lotno] => 3207 [count] => 240 ))

Code 34th lines
Print_r ($ a); // The result is the correspondence between stockno and cust_no. In this example, the relationship is 1 to 2.

Array ([0] => Array ([0] => 09:00:00 [1] => L11K [2] => 23703EX80A [3] => 15 [4] => 8 [5] = & gt; 120) [1] => Array ([0] => 09:00:00 [1] => L11K [2] => 23703EX80A [3] => 15 [4] => 9 [5] => 135)

In this example, the result of the second item may not be satisfied (this is not possible in actual situations. if so, the system prompts that the number is insufficient ), 3207*120 (240-120 of the first item) is displayed, and then other situations are supplemented, such as 3207*120.
3209*15.

#9 the data is not comprehensive enough. I will re-post a new one.

Code 26th lines
Print_r ($ arrs); // obtain the total inventory of the cust_no.

Array ([0] => Array ([lotno] => 3207 [count] => 240) [1] = & gt; Array ([lotno] = & gt; 3209 [count] = & gt; 165) [2] => Array ([lotno] => 3210 [count] => 360 ))

Code 34th lines
Print_r ($ a); // The result is the correspondence between stockno and cust_no. In this example, the relationship is 1 to 2.

When stockno = 1:
Array ([0] => Array ([0] => 09:00:00 [1] => L11K [2] => 23703EX80A [3] => 15 [4] => 8 [5] = & gt; 120) [1] => Array ([0] => 09:00:00 [1] => L11K [2] => 23703EX80A [3] => 15 [4] => 9 [5] => 135 ))

When stockno = 2:
Array ([0] => Array ([0] => 09:00:00 [1] => L11K [2] => 23703EX80A [3] => 15 [4] => 10 [5] = & gt; 150) [1] => Array ([0] => 09:00:00 [1] => L11K [2] => 23703EX80A [3] => 15 [4] => 10 [5] => 150 ))

... And so on

Expected results:
When stockno = 1:

Purple Line 1: 3207*120

Purple Row 2: 3207*120
3209*15

When stockno = 2:

Purple Line 1: 3209*150

Purple Row 2: 3210*150

... And so on to stockno = n.

Results like this.

So?

$arrs = Array (  0 => Array ( 'lotno' => 3207, 'count' => 240 ),  1 => Array ( 'lotno' => 3209, 'count' => 165 ),  2 => Array ( 'lotno' => 3210, 'count' => 360 ),);$a = Array(  0 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4 => 8, 5 => 120),  1 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4 => 9, 5 => 135),  2 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4=> 10, 5 => 150),  3 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4=> 10, 5 => 150),);
The two groups of data are not equal. how do you know who is stockno?

So?

$arrs = Array (  0 => Array ( 'lotno' => 3207, 'count' => 240 ),  1 => Array ( 'lotno' => 3209, 'count' => 165 ),  2 => Array ( 'lotno' => 3210, 'count' => 360 ),);$a = Array(  0 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4 => 8, 5 => 120),  1 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4 => 9, 5 => 135),  2 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4=> 10, 5 => 150),  3 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4=> 10, 5 => 150),);
The two groups of data are not equal. how do you know who is stockno?

The original situation is as follows,
$ Stockno = explode ("," $ _ GET ['stockno']);
For ($ j = 0; $ j <count ($ stockno); $ j ++)
{
// Put the 1 # code in this loop;
}

Can you think of data as this?

$arrs = Array (  0 => Array ( 'lotno' => 3207, 'count' => 240 ),  1 => Array ( 'lotno' => 3209, 'count' => 165 ),  2 => Array ( 'lotno' => 3210, 'count' => 360 ),);$a = Array(stockno1 =>Array(  0 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4 => 8, 5 => 120))  1 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4 => 9, 5 => 135))), Array(stockno2 =>Array(0 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4=> 10, 5 => 150),  1 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4=> 10, 5 => 150)));


So?

$arrs = Array (  0 => Array ( 'lotno' => 3207, 'count' => 240 ),  1 => Array ( 'lotno' => 3209, 'count' => 165 ),  2 => Array ( 'lotno' => 3210, 'count' => 360 ),);$a = Array(  0 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4 => 8, 5 => 120),  1 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4 => 9, 5 => 135),  2 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4=> 10, 5 => 150),  3 => Array(0 => '2013-05-13 09:00:00', 1 => 'L11K', 2 => '23703EX80A', 3 => 15, 4=> 10, 5 => 150),);
The two groups of data are not equal. how do you know who is stockno?

Or:
$arrs = Array (  0 => Array ( 'lotno' => 3207, 'count' => 240 ),  1 => Array ( 'lotno' => 3209, 'count' => 165 ),  2 => Array ( 'lotno' => 3210, 'count' => 360 ),);$a = Array(stockno1 =>Array(0 => Array(5 => 120),1 => Array(5 => 135)), Array(stockno2 =>Array(0 => Array(5 => 150),1 => Array(5 => 150)));

Wrong,

$arrs = Array (  0 => Array ( 'lotno' => 3207, 'count' => 240 ),  1 => Array ( 'lotno' => 3209, 'count' => 165 ),  2 => Array ( 'lotno' => 3210, 'count' => 360 ),);$a = Array(stockno1 =>Array(0 => Array(5 => 120),1 => Array(5 => 135)),stockno2 =>Array(0 => Array(5 => 150),1 => Array(5 => 150)));

Based on what can you associate these two groups of data?

For example, if you read $ a ['stockno1'] [1] [5], how do I know whether the corresponding parameter is $ arrs [0], $ arrs [1], or $ arrs [2]?

Based on what can you associate these two groups of data?

For example, if you read $ a ['stockno1'] [1] [5], how do I know whether the corresponding parameter is $ arrs [0], $ arrs [1], or $ arrs [2]?

This is the association in the program. First obtain the stockno value, then obtain the corresponding cust_no, and then obtain the total number of corresponding lotno through cust_no.
The code contains 2-26 lines. As for how to associate $ arrs with $ a, can we sort the result of the obtained stockno and then assign $ arrs to $ a according to the sorting result?

Stockno sorting code:

$sql = "select count(*) from (select stock_no,count(stock_no) from "`.$t."` where adress like 'A%' group by stock_no) as temp";$result = mysql_query($sql);$row = mysql_fetch_array($result);$sql2 = "SELECT stock_no FROM `stock_detail` WHERE adress LIKE 'A%' GROUP BY stock_no ORDER BY adress, arr_time, c_type ASC";$result2 = mysql_query($sql2);$var = array();while($row1 = mysql_fetch_array($result2,MYSQL_NUM)){$var[] = $row1;}for($x=0;$x<=$row['0'];$x++){if($var[$x][0] == $stockno)echo ($x+1);}

The problem is that your $ arrs and $ a come from two unrelated tables respectively, so you need to find the relationship between the two.
Because you actually output $ a, you should obtain the corresponding $ arrs after obtaining $.
In this way, it is easy to output

The problem is that your $ arrs and $ a come from two unrelated tables respectively, so you need to find the relationship between the two.
Because you actually output $ a, you should obtain the corresponding $ arrs after obtaining $.
In this way, it is easy to output
Okay. I will try it tomorrow. Thank you for your reply.

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.