Find the corresponding relationship in an array

Source: Internet
Author: User
This post was last edited by lazygc520 on 2013-07-03 12:12:16

Array 1:array ([0] = = Array ([cust_no] = 237033aw0a [Lotno] = 3207 [lot                    No_count] + 360)) array 2:array ([SU13061301033]/= Array ([0] = = Array (                    [0] = 2013-06-19 09:00:00 [1] = x02b [2] = 237033aw0a [3] = [4] = [5] = 210)] [ SU13061301032] = Array ([0] = = Array ([0] = 2013-06-19 09                    : 00:00 [1] = x02b [2] = 237033aw0a [3] = 15            [4] = [5] = 255)) [SU13061301037] = = Array (                     [0] = = Array ([0] = 2013-06-19 09:00:00 [1] = = x11q [2]= 237033aw0a [3] = [4] = 3 [5] = 45  ) [1] = = Array ([0] = 2013-06-19 09:00:00 [1]                    = x11q [2] = 237033aw0a [3] = [4] = 2 [5] = 30)) array 3:array ([0] = SU13061301033 [1] = = SU13061301032 [2] = SU13061301037)

Array 1 represents the total quantity obtained.
Array 2 represents the number of stockno (the beginning of the SU) when the value is the [5] item.
The array 3 represents the sequence of stockno in the array.

Can be evaluated according to the sequence of array 3,
When Stockno is SU13061301033, the first 210 items corresponding to array 1 correspond to Stockno SU13061301033,
When Stockno is SU13061301032, the remaining items in the corresponding array 1 correspond to Stockno as SU13061301033.
This is the case in turn.

Is there such a correspondence?


Reply to discussion (solution)

Your array 1 doesn't have just one set of data?

Your array 1 doesn't have just one set of data?
So it doesn't match, does it? Arrays 1 and 3 only have correspondence to obtain results.

If you can't find a corresponding relationship, you can't get the value you need?

corresponding to the first 210 items in array 1 What does this say?

corresponding to the first 210 items in array 1 What does this say?
I mean, the Stockno in array 3 is in front, such as the first item SU13061301033, and the value in the corresponding array 2 is 210. Then the total number in the array 1 to allocate 210 of this value, the following stockno with the total number of results-210 to allocate the next set of values.
PS: There may be a problem, so I'm going to look at the SQL statement again. I'll get back to you later.

If you use a line, you can.
But the key is the dependency between your data.

If you use a line, you can.
But the key is the dependency between your data.
Good. I'll be under your guidance tomorrow.

I need you to clear your mind.
When pasting data, the invitation var_export results, not print_r results
Convenient for people, with their own convenience

Problem with the resulting storage

I need you to clear your mind.
When pasting data, the invitation var_export results, not print_r results
Convenient for people, with their own convenience

There are three tables: Kw_manage,vp_barcode_2d_y,stock_detail, corresponding to inventory, inventory corresponding batch lotno, out of the library information.

Inventory to Packageno as a unit of warehousing, through vp_barcode_2d_y This table to obtain the Packageno corresponding batch Lotno and quantity, cust_no, out of the library Stock_detail contains information stock_no, Corresponding relationship: A stock_no corresponds to multiple cust_no and corresponding quantities.
For example the following:

SU13061301012 (stock_no) A2 2013-06-19 09:00:00 b12d (3) k25b460 237033aw0a (cust_no) 10 15 2013-06-15 15:00:00 2013-06-15 15 : 30:00su13061301012 (stock_no)  A2 2013-06-19 09:00:00 b12d (3) k25b459 237033aw0a (cust_no) 10 15 2013-06-15 15:00:00 2013-06-15 15:30:00

PS: Figure of 10*15 (number of boxes * per box)
That is to say stock_no and packageno between no inevitable contact, whether can by batch Lotno first in first come out to deal with the correspondence relation?
Or what part of the var_export you need?

or slightly specific varieties, that is, a discussion value for a single breed
Storage batch and quantity two attributes
There are two properties for out-of-library batches and quantities when out of the library

You seem to need statistics: which batches are in the warehouse

I understand, right?

or slightly specific varieties, that is, a discussion value for a single breed
Storage batch and quantity two attributes
There are two properties for out-of-library batches and quantities when out of the library

You seem to need statistics: which batches are in the warehouse

I understand, right?
That's it. Understand correctly.

Usually, I am the normal storage, and then according to the requirements of the library (Stock_detail table) with the information in the storage to match the requirements.

inbound:

CREATE TABLE ' kw_manage ' (' ID ' int (one) not NULL auto_increment, ' username ' varchar (ten) NOT null, ' rkno ' varchar) NO T null, ' Packageno ' varchar (a) NOT null, ' type ' varchar (a) NOT null, ' cust_no ' varchar (4) is not NULL, ' SNP ' int.  T null, ' wh_info ' varchar (not null), ' Date ' datetime is NOT NULL, PRIMARY key (' ID '), key ' Packageno ' (' Packageno '), KEY ' Date ' (' Date ')) Engine=myisam;insert into ' Kw_manage ' VALUES (1, ' admin ', ' 201302190001 ', ' VP3.0 130219001 ', ' BEM330 -500 ', ' 23703 3aw0a ', ' ye-00-01 ', ' 2013-06-27 10:56:10 '); INSERT into ' Kw_manage ' VALUES (2, ' admin ', ' 201302190001 ', ' VP3.0 130219002 ', ' bem330-500 ', ' 23703 3aw0a ', and ' ye-00-01 ', ' 2013-06-27 10:56:12 '); INSERT into ' Kw_manage ' VALUES (3, ' Admin ', ' 201302190001 ', ' VP3.0 130219003 ', ' bem330-500 ', ' 23703 3aw0a ', ', ' ye-00-01 ', ' 2013-06-27 10:56:14 '); INSERT INT O ' Kw_manage ' VALUES (4, ' admin ', ' 201302190001 ', ' VP3.0 130219004 ', ' bem330-500 ', ' 23703 3aw0a ', and ' ye-00-01 ', ' 2013-06 -28 08:45:20 '); INSERT INTO ' Kw_manage ' VALUES (5, ' admin ', ' 201302190001 ', ' VP3.0 130219005 ', ' bem330-500 ', ' 23703 3aw0a ', and ' ye-00-01 ', ' 2013-06  -28 08:45:23 '); INSERT into ' Kw_manage ' VALUES (6, ' admin ', ' 201302190001 ', ' VP3.0 130219006 ', ' bem330-500 ', ' 23703 3aw0a ', ' ye-00-01 ', ' 2013-06-28 08:45:26 '); INSERT into ' Kw_manage ' VALUES (7, ' admin ', ' 201302190001 ', ' VP3.0 130219007 ', ' be M330-500 ', ' 23703 3aw0a ',, ' ye-00-01 ', ' 2013-06-28 08:45:28 '); INSERT into ' Kw_manage ' VALUES (8, ' admin ', ' 201302190001 ', ' VP3.0 130219008 ', ' bem330-500 ', ' 23703 ', ' 3aw0a ', ' ye-00-01 2013-06-28 '; INSERT into ' 08:45:30 ' VALUES (  9, ' admin ', ' 201302190001 ', ' VP3.0 130219009 ', ' bem330-500 ', ' 23703 3aw0a ', ' ye-00-01 ', ' 2013-06-28 08:45:32 '); INSERT Into ' kw_manage ' VALUES, ' admin ', ' 201302190001 ', ' VP3.0 130219010 ', ' bem330-500 ', ' 23703 3aw0a ', ' ye-00-01 ', ' 20 13-06-28 08:45:35 '); INSERT into ' kw_manage ' VALUES (one, ' admin ', ' 201302190001 ', ' VP3.0 130219011 ', ' bem330-500 ', ' 23703 3 aw0a ', ' ye-00-01 ', ' 2013-06-28 08:45:38 '); INSERT into ' kw_manage ' VALUES (' admin ', ' 201302190001 ', ' VP3.0 130219012 ', ' bem330-500 ', ' 23703 3aw0a ', ' ye-00-01 ', ' 2013-06-28 08:45:42 '); INSERT into ' kw_manage ' VALUES (' admin ', ' 201302190002 ', ' VP3.0 130219 013 ', ' bem330-500 ', ' 23703 3aw0a ', and ' ye-00-01 ', ' the 2013-06-28 08:46:06 '); INSERT into ' kw_manage ' VALUES (' admin ', ' 20 1302190002 ', ' VP3.0 130219014 ', ' bem330-500 ', ' 23703 3aw0a ', and ' ye-00-01 ', ' 2013-06-28 08:46:09 '); INSERT into ' Kw_manag E ' VALUES (+, ' admin ', ' 201302190002 ', ' VP3.0 130219015 ', ' bem330-500 ', ' 23703 3aw0a ', ' ye-00-01 ', ' 2013-06-28 08:46: INSERT into ' kw_manage ' VALUES (+, ' admin ', ' 201302190002 ', ' VP3.0 130219016 ', ' bem330-500 ', ' 23703 3aw0a ', ' ye-') 00-01 ', ' 2013-06-28 08:46:13 '); INSERT into ' kw_manage ' VALUES (+, ' admin ', ' 201302190002 ', ' VP3.0 130219017 ', ' bem330-50 0 ', ' 23703 3aw0a ', ' ye-00-01 ', ' 2013-06-28 08:46:15 '); INSERT into ' kw_manage ' VALUES (' admin ', ' 201302190002 ', ' VP 3.0 130219018 ', ' bem330-500', ' 23703 3aw0a ', ' ye-00-01 ', ' 2013-06-28 08:46:18 '); INSERT into ' kw_manage ' VALUES (' admin ', ' 201302190002 ', ' VP3 .0 130219019 ', ' bem330-500 ', ' 23703 3aw0a ', [ye-00-01 ', ' 2013-06-28 '); INSERT into ' 08:46:19 ' VALUES (AD Min ', ' 201302190002 ', ' VP3.0 130219020 ', ' bem330-500 ', ' 23703 3aw0a ',, ' ye-00-01 ', ' 2013-06-28 08:46:22 '); INSERT into ' Kw_manage ' VALUES, ' admin ', ' 201302190002 ', ' VP3.0 130219021 ', ' bem330-500 ', ' 23703 3aw0a ', ' ye-00-01 ', ' 2013-06-2 8 08:46:27 '); INSERT into ' kw_manage ' VALUES (' admin ', ' 201302190002 ', ' VP3.0 130219022 ', ' bem330-500 ', ' 23703 3aw0a ', ' ye-00-01 ', ' 2013-06-28 08:46:30 '); INSERT into ' Kw_manage ' VALUES ($, ' admin ', ' 201302190002 ', ' VP3.0 130219023 ', ' be M330-500 ', ' 23703 3aw0a ',, ' ye-00-01 ', ' 2013-06-28 08:46:33 '); INSERT into ' kw_manage ' VALUES (' admin ', ' 20130219000 2 ', ' VP3.0 130219024 ', ' bem330-500 ', ' 23703 3aw0a ', and ' ye-00-01 ', ' 2013-06-28 08:46:36 '); INSERT into ' kw_manage ' VALUES (+, ' admin ', ' 201302190023 ', ' VP3.0 130219048 ', ' mec718-000 ', ' 23710 je22a ',, ' yq-00-01 ', ' 2013-07-08 11:16:57 '); INSERT into ' kw_manage ' VALUE S (+, ' admin ', ' 201302190023 ', ' VP3.0 130219049 ', ' mec718-000 ', ' 23710 je22a ', ' yq-00-01 ', ' 2013-07-08 11:17:01 '); INS ERT into ' kw_manage ' VALUES (' admin ', ' 201302190023 ', ' VP3.0 130219050 ', ' mec718-000 ', ' 23710 je22a ', ' yq-00-01 ', ' 2013-07-08 11:17:08 '); INSERT into ' kw_manage ' VALUES (' admin ', ' 201302190023 ', ' VP3.0 130219051 ', ' mec718-000 ', ' 237 Ten je22a ', ' yq-00-01 ', ' 2013-07-08 11:17:13 '); INSERT into ' kw_manage ' VALUES (' admin ', ' 201302190023 ', ' VP3.0 1302 19052 ', ' mec718-000 ', ' 23710 je22a ', ', ' yq-00-01 ', ' 2013-07-08 11:17:23 '); INSERT into ' kw_manage ' VALUES (' admin ', ' 201302190023 ', ' VP3.0 130219053 ', ' mec718-000 ', ' 23710 je22a ', and ' yq-00-01 ', ' 2013-07-08 11:17:30 '); INSERT into ' Kw_man Age ' VALUES ', ' admin ', ' 201302190023 ', ' VP3.0 130219054 ', ' mec718-000 ', ' 23710 je22a ', ' yq-00-01 ', ' 2013-07-08 11:1 7:39 '); INSERT into ' Kw_manAge ' VALUES (+, ' admin ', ' 201302190023 ', ' VP3.0 130219055 ', ' mec718-000 ', ' 23710 je22a ', ' yq-00-01 ', ' 2013-07-08 11:1 7:54 ');

In the principle of FIFO, the process of the library is as follows:
Number of outbound libraries known
Traverse the inbound table to deduct the quantity of the current inbound batch from the number of outbound libraries until the number of outbound libraries is less than or equal to 0
If the number of out-of-stock is negative, the absolute value is added back

In the principle of FIFO, the process of the library is as follows:
Number of outbound libraries known
Traverse the inbound table to deduct the quantity of the current inbound batch from the number of outbound libraries until the number of outbound libraries is less than or equal to 0
If the number of out-of-stock is negative, the absolute value is added back
Out of the library:

$sql 4 = "Select Arr_time,c_type,cust_no,snp,mount,mount*snp as M_total,stock_no from". $t. " ' Where Stock_no = '. $stockno [$j-1]. "'"; /echo $sql 4. '
'; $result 4 = mysql_query ($sql 4); $ar = Array (); while ($var = mysql_fetch_array ($result 4,mysql_num)) {$ar [] = $var;} $a = Array (), foreach ($ar as $item) { $key = Array_pop ($item); if (! isset ($a [$key])) $a [$key] = array (); $a [$key] = $item;} Var_xeport Result: Array (' SU13061301033 ' = = Array (0 = = Array (0 = ' 2013-06-19 09:00:00 ', 1 = ' x02b ', 2 = ' 237033aw0a ', 3 = ' 4 ', 5 = ' 210 ',),)


Storage:
$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 (); Sets an array to hold the result ($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,packageno ORDER by lotno ASC ';//echo $sql 2. '

What do you mean by the code you put in the library?

What do you mean by the code you put in the library?
Do not need to know the total amount of storage? How to determine the batch has been matched, not back in the results of other stock_no?

The data and code you gave are not matched
Unknown column ' Arr_time ' in ' Field list '

Just out of the library of data did not give the whole, not affixed. Now fill it up.

CREATE TABLE ' stock_detail ' (' ID ' int (one) not null auto_increment, ' stock_no ' varchar () is not null, ' adress ' varchar (TEN) N OT null, ' arr_time ' datetime NOT NULL, ' c_type ' varchar (a) NOT null, ' pu_no ' varchar (a) NOT null, ' cust_no ' varchar (NO)  NULL, ' Mount ' int (ten) is not null, ' SNP ' Int (ten) not null, ' C1_time ' datetime is NOT NULL, ' c2_time ' datetime NOT NULL, PRIMARY KEY (' ID ')) Engine=myisam;insert into ' stock_detail ' VALUES (' SU13061301029 ', ' B ', ' 2013-06-20 22:00:00 ', ' p32l ', ' k25k498 ', ' 310 F61va5a ', 9, +, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT into ' Stock_detail ' VALUES (+, ' SU13061301029 ', ' B ') , ' 2013-06-20 22:00:00 ', ' p32l ', ' k25k497 ', ' 310f61va5a ', ten, +, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT INT O ' Stock_detail ' VALUES (SU13061301031, ' A1 ', ' 2013-06-20 09:00:00 ', ' x02b ', ' k25b418 ', ' 237033aw0a ', 14, 15, ' 2013- 06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT into ' Stock_detail ' VALUES (' SU13061301030 ', ' A1 ', ' 2013-06-20 09:00:0 0 ', ' x02b ', ' k25b417 ', ' 237033aw0a ', ' n ', ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT into ' Stock_detail ' VALUES (' SU130613 ' 01033 ', ' A1 ', ' 2013-06-19 09:00:00 ', ' x02b ', ' k25b416 ', ' 237033aw0a ', 14, 15, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 ' INSERT into ' stock_detail ' VALUES (' SU13061301032 ', ' A1 ', ' 2013-06-19 09:00:00 ', ' x02b ', ' k25b415 ', ' 237033aw0a ', 17 , ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT into ' Stock_detail ' VALUES (' SU13061301034 ', ' A1 ', ' 2013-06 -19 09:00:00 ', ' x11q ', ' k25b407 ', ' 237033aw0a ', 6, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT into ' stock_de Tail ' VALUES, ' SU13061301034 ', ' A1 ', ' 2013-06-19 09:00:00 ', ' x11q ', ' k25b408 ', ' 237033aw0a ', 9, 15, ' 2013-06-15 15:00: xx ', ' 2013-06-15 15:30:00 '); INSERT into ' Stock_detail ' VALUES (' SU13061301035 ', ' A1 ', ' 2013-06-20 09:00:00 ', ' x11q ', ' k25b409 ', ' 237033aw0a ', 7, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT into ' Stock_detail ' VALUES (Wuyi, ' SU130 61301035 ', ' A1 ', ' 2013-06-20 09:00:00 ', ' x11q ', ' k25b410 ', ' 237033aw0a ', 9, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT into ' stock_d Etail ' VALUES (SU13061301036, ' A1 ', ' 2013-06-20 09:00:00 ', ' x11q ', ' k25b434 ', ' 237033aw0a ', 3, 15, ' 2013-06-15 15:00  : xx ', ' 2013-06-15 15:30:00 '); INSERT into ' Stock_detail ' VALUES (' SU13061301036 ', ' A1 ', ' 2013-06-20 09:00:00 ', ' x11q ', ' k25b433 ', ' 237033aw0a ', 2, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT into ' Stock_detail ' VALUES (' SU1 ' 3061301037 ', ' A1 ', ' 2013-06-19 09:00:00 ', ' x11q ', ' k25b431 ', ' 237033aw0a ', 3, 15, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30 : xx '); INSERT into ' Stock_detail ' VALUES (SU13061301037 ', ' A1 ', ' 2013-06-19 09:00:00 ', ' x11q ', ' k25b432 ', ' 237033aw0a ', 2, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT into ' Stock_detail ' VALUES (' SU13061500001 ', ' A1 ', ' 201 3-06-20 09:00:00 ', ' l11k ', ' c6e0085 ', ' 23703ex80a ', 2, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30:00 '); INSERT into ' stoc K_detail ' VALUES (SU1, '3061500002 ', ' A1 ', ' 2013-06-20 09:00:00 ', ' x11q ', ' c6e0084 ', ' 237033aw0a ', 1, 15, ' 2013-06-15 15:00:00 ', ' 2013-06-15 15:30 : 00 ');

The data and code you gave are not matched
Unknown column ' Arr_time ' in ' Field list '
Tired of seeing 20#

In the principle of FIFO, the process of the library is as follows:
Number of outbound libraries known
Traverse the inbound table to deduct the quantity of the current inbound batch from the number of outbound libraries until the number of outbound libraries is less than or equal to 0
If the number of out-of-stock is negative, the absolute value is added back

Please give an example, do not understand the meaning of this sentence.
Traverse the inbound table to deduct the number of current inbound batches from the number of out-of-stock

  • 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.