Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial PHP中如何制作查询报表

PHP中如何制作查询报表

Jun 23, 2016 pm 01:34 PM

数据库:MSD
表:PURTC、PURTD
PURTC中的字段:


PURTD中的字段:


------------------------------条件区-----------------------------------


----------------------------数据显示区----------------------------------


希望可以给出源码,谢谢


回复讨论(解决方案)

不说别的,就这数据库设计,就没有写代码的欲望

其实这是鼎捷的易飞ERP系统的数据库,我只是列出部分的字段供参考,我只是个菜鸟,不知道什么样的数据库设计才能勾起你写代码的欲望....

楼上的应该期望字段名称至少是英文的。

长见识了:) 

既然是别人的erp系统 楼主还是看看他们的数据表结构吧

他们的表结构我非常了解,但我的问题好像跟表结构没多大的联系

以"单别"作为关联,连表查询就可以了。


这个数据表设计确实有问题,
两个表竟然只有一个numeric类型的字段。
很多列其实都是枚举值。如果值是枚举值的话,不应该直接定义为char或varchar类型。可以用tinyint类型来做个标号,然后再加张表与此表做关联。

这样能保证数据的一致性,而且由于是数值型,作为where条件筛选或关联键,查询速度也会很快。

从设计范式来讲严重不符合,从实际使用角度讲,也没什么好处。不要认为这是xx的系统,他们的代码就一定好。尤其是国内的程序代码。

以"单别"作为关联,连表查询就可以了。


这个数据表设计确实有问题,
两个表竟然只有一个numeric类型的字段。
很多列其实都是枚举值。如果值是枚举值的话,不应该直接定义为char或varchar类型。可以用tinyint类型来做个标号,然后再加张表与此表做关联。

这样能保证数据的一致性,而且由于是数值型,作为where条件筛选或关联键,查询速度也会很……



谢谢您的分析,能否根据我的问题给出详细的代码,我真正想要的是:当点击条件区的 查询按钮 时,怎么才能让它根据我填入的条件进行查询?

引用 7 楼 ShadowSniper 的回复:以"单别"作为关联,连表查询就可以了。


这个数据表设计确实有问题,
两个表竟然只有一个numeric类型的字段。
很多列其实都是枚举值。如果值是枚举值的话,不应该直接定义为char或varchar类型。可以用tinyint类型来做个标号,然后再加张表与此表做关联。

这样能保证数据的一致性,而且由于是数值型……

楼主到底想要报表类还是要查询???

是的,需求功能是怎么样呀


通过这里设置的条件进行查询,得到结果数据并分页

查询无非就是 连接 where 子语句 
单个 select * from user where userid=? 
多个 select * from user where userid=? && username=?
复杂点的就多表查询 原理也是一样的
你能够从数据库中获取到你想要数据,接下来你爱怎么显示,爱怎么处理就随你了。包括分页处理。

不就是个动态生成查询条件的问题吗?

基础查询指令:
select * from PURTC, PURTD where tc001=td001 and tc002=td002
根据输出要求自行调整

设表单为post方式的,表单对象与字段同名,提交按钮不命名
生成代码
$s = '';
foreach($_POST as $k=>$v) {
  if(! empty($v)) $s .= " and $k='$v'";
}
将 $s 附加在基础指令之后,查询、显示
请自行加入合法性验证代码

楼上的都说了~~结贴吧

可我还是不会啊,能否把全部代码贴上来呀?

随便灌灌水, 下载要积分呀

感觉finereport的查询功能不用编码就能实现的,你这个需求建议还是最好用finereport做做看吧~

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

What exactly is the non-blocking feature of ReactPHP? How to handle its blocking I/O operations? What exactly is the non-blocking feature of ReactPHP? How to handle its blocking I/O operations? Apr 01, 2025 pm 03:09 PM

An official introduction to the non-blocking feature of ReactPHP in-depth interpretation of ReactPHP's non-blocking feature has aroused many developers' questions: "ReactPHPisnon-blockingbydefault...

See all articles