Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 复选框操作数据库的问题

复选框操作数据库的问题

Jun 23, 2016 pm 02:04 PM

表名:sale_order
表结构:
ID
order_id
name
quantity
Price
Address
Region

现在是这样,这个表内容我会显示在一个页面上,然后每条记录有个复选框,复选想要处理的记录,点提交

把复选的数据汇总处理

我的问题是怎么对选择的数据进行处理,对整个表的数据进行汇总我会。


回复讨论(解决方案)

不知道你要怎么处理,请详细说明。

例:
id,order_id, name,quantity,price,adderess,region
01,00001,王刚,10,500,深圳龙岗,HK
02,00002,王刚,5,200,深圳龙岗,HK
03,00003,刘二,6,300,东莞,HK
04,00004,刘二,5,400,东莞,CN
05,00005,王五,7,125,湖南,CN
06,00007,李四,1,454,北京,CN

一般我们汇总把人名一样的汇总在一起,汇总结果:
王刚,深圳龙岗,10X500****、5X200****,HK
刘二,东莞,6X300****、5X400****,HK
王五,湖南,5X400****,CN
李四,北京,1X454,CN

人名一样的把数量和价格汇总在一起,数量大于1的后面加*号,如果里面有一个HK,region就是HK

我现在就是想让操作的人自己选择要处理的数据进行处理。

在输出到页面的时候,给每条记录前加一个" />,我想你的问题可能就是这个value属性值,很简单,像我这样,把value=""中间再插入PHP代码,然后把你记录的数据通过echo输出,这样在点击处理数据之后,就可以在$_POST['checkbox']里找到数据了,你可以var_dump($_POST['checkbox']);看一下

stneo1990谢谢你的解答,可能我没说明白,把id或order_id赋值给value属性传过去,然后循环操作每记录,这个我知道。。。。。。。我现在主要是想对选择的数据进行汇总

SELECT * , group_concat('  ' , concat_ws( ' X ', `sku` , `quantity-purchased` ) , if(`quantity-purchased`> 1, '****' , '  ') ),group_concat('  ' , `order_id` , '  ') FROM ( select * from `sale_orders` order by `sku`) T WHERE `shipments` =0 AND `number` =$id AND (1<(select count(*) from `sale_orders` where `recipient-name`=T.`recipient-name`) OR `quantity-purchased`>1)  GROUP BY `recipient-name` , `ship-address-1` ORDER BY length(group_concat( ' ' , concat_ws( ' X ', `sku` , `quantity-purchased` ) , ' ' )) DESC,`sku`
Copy after login

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
3 weeks 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)

PHP Logging: Best Practices for PHP Log Analysis PHP Logging: Best Practices for PHP Log Analysis Mar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

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.

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

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

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.

See all articles