How to create a query report in PHP

Source: Internet
Author: User
How to create a query report in PHP Database: MSD
Table: PURTC, PURTD
Fields in PURTC:


Fields in PURTD:


------------------------------ Condition zone -----------------------------------


---------------------------- Data display area ----------------------------------


Hope you can provide the source code. thank you.


Reply to discussion (solution)

With nothing more, there is no desire to write code in this database design.

In fact, this is the database of Dingjie's Yifei ERP system. I only list some fields for reference. I am just a Cainiao, I don't know what kind of database design can bring up your desire to write code ....

The field names upstairs should be expected to be at least in English.

Long knowledge :)

Since it's someone else's erp system, let's look at their data table structure.

I know very well about their table structure, but my problem seems to be not very relevant to the table structure.

Join the table with "standalone.


There is indeed a problem with the design of this data table,
The two tables have only one numeric field.
Many columns are actually enumeration values. If the value is an enumerated value, it should not be directly defined as char or varchar. You can use the tinyint type to create a label, and then add a table to associate the table.

This ensures data consistency, and because it is a numeric type, as a where filter condition or associated key, the query speed will be very fast.

From the perspective of design paradigm, there is no benefit in actual use. Don't think this is a xx system, and their code will be fine. Especially domestic program code.

Join the table with "standalone.


There is indeed a problem with the design of this data table,
The two tables have only one numeric field.
Many columns are actually enumeration values. If the value is an enumerated value, it should not be directly defined as char or varchar. You can use the tinyint type to create a label, and then add a table to associate the table.

This ensures data consistency, and because it is a numeric type, as a where filter condition or associated key, the query speed will also be very high ......



Thank you for your analysis. can you provide detailed code based on my questions? what I really want is: when you click the search button in the condition area, how can I make it query based on the conditions I have filled in?

Reference the reply from ShadowSniper on the 7th floor: join the table with "standalone.


There is indeed a problem with the design of this data table,
The two tables have only one numeric field.
Many columns are actually enumeration values. If the value is an enumerated value, it should not be directly defined as char or varchar. You can use the tinyint type to create a label, and then add a table to associate the table.

In this way, data consistency can be ensured ......

Do I want to query the report type ???

Yes. What are the required functions?


Use the conditions set here to query the results.

A query is nothing more than a where substatement.
Single select * from user where userid =?
Multiple select * from user where userid =? & Amp; username =?
The principle of multi-table queries for complex points is the same.
You can get the data you want from the database, and then you can show how you like it and how you do it. Including paging.

Isn't it a question about dynamically generating query conditions?

Basic query command:
Select * from PURTC, PURTD where tc001 = td001 and tc002 = td002
Adjusted according to output requirements

If the form is set to post, the form object and field have the same name. the submit button is not named.
Generate code
$ S = '';
Foreach ($ _ POST as $ k => $ v ){
If (! Empty ($ v) $ s. = "and $ k = '$ V '";
}
After attaching $ s to the basic command, query and display
Please add your own legality verification code

I spoke about everything upstairs ~~ Close the post

But I still don't know. can I paste all the code?

Add credits for downloading.

I feel that the query function of finereport can be implemented without coding. you 'd better use finereport for this requirement ~

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.