复选数据汇总问题
复选框,如果我想对选择的数据进行group_concat()操作,请问怎么做呢?
回复讨论(解决方案)
$in=implode(',',$_POST['id']); //假设复选框name为id[]$sql="select id, group_concat(name) from tt where id in($in) group by id";...
谢谢jordan102大大的解答
我还想问一个问题,一般一个页面一次显示的数据都是10,20条左右,但有时候我这里需要一次选择1000条或者显示的数据要全选,然后取消不要的复选框勾勾。这种情况一般怎么样操作呢???
贴出你的代码看看
晕倒,回复了十几遍了
前台源码
<link rel="stylesheet" type="text/css" href="css/css.css" /><!--<link rel="stylesheet" type="text/css" href="css/style.css" />--><style type="text/css"> * { padding:0; margin:0; } body { font-family:verdana; font-size:12px; margin-left: 0px; margin-top: 0px; } .content { width:700px; margin:20px 10px; } .content h1 { font-family:'??'; font-size:18px; padding-bottom:5px; } table { width:100%; } th, td { padding:6px 0; text-align:center; } th { background-color:#accdf4; color:#ffffff; } tr { background-color:#FFFFFE; } .odd { background-color:#FFFAFF; } .highlight { background-color:#E0E0E0;}.STYLE3 {font-size: 14px}</style><script type="text/javascript"> //?jsclass function addClass(element, value) { if(!element.className) { element.className = value; //element?class,?class?value? } else { element.className += " "+value; //element???class??м???,??value? } } //л? function stripeTable() { var tables = document.getElementsByTagName("table"); //?еtable for(var i=0; i<tables.length; i++) { var rows = document.getElementsByTagName("tr"); for(var j=0; j<rows.length; j++) { if(j%2 == 0) { addClass(rows[j], "odd"); //?Уclass?odd //rows[j].setAttribute("class", "odd"); } } } } //??? function highlightRows() { var rows = document.getElementsByTagName("tr"); for(var i=0; i<rows.length; i++) { rows[i].oldClassName = rows[i].className; //???class? rows[i].onmouseover = function() { addClass(this, "highlight"); //??class?highlight? } rows[i].onmouseout = function() { this.className = this.oldClassName; //?????class? } } } window.onload = function() { stripeTable(); highlightRows(); } </script><script language="javascript"> // --列头全选框被单击--- function ChkAllClick(sonName, cbAllId){ var arrSon = document.getElementsByName(sonName); var cbAll = document.getElementById(cbAllId); var tempState=cbAll.checked; for(i=0;i<arrSon.length;i++) { if(arrSon[i].checked!=tempState) arrSon[i].click(); } } // --子项复选框被单击--- function ChkSonClick(sonName, cbAllId) { var arrSon = document.getElementsByName(sonName); var cbAll = document.getElementById(cbAllId); for(var i=0; i<arrSon.length; i++) { if(!arrSon[i].checked) { cbAll.checked = false; return; } } cbAll.checked = true; } </script><h2 id="SKU对照表">SKU对照表</h2><div class="content"><?PHPinclude_once ("page.class.php");include_once ("conn.php");$pageSize=10; if(empty($_GET['page'])) { $spage=1; } else { $spage=$_GET['page']; }$start=$spage*$pageSize-$pageSize;$result = mysql_query("SELECT COUNT(*) AS count FROM `sku_rule`");$row = mysql_fetch_array($result); $total= $row['count'];$SQL = "SELECT * FROM `sku_rule` LIMIT $start , $pageSize"; $result = mysql_query($SQL);pageft($total,$pageSize,1,1,1,5);?><div id="opt"> <div id="query"> <label></label> <select name="skuziduan[]"> <option value="sku" selected="selected" >SKU</option> <option value="sale_sku" >订单SKU</option> </select> <input type="text" class="input" id="product_name" /> <input type="submit" class="btn" id="find_btn" value="查 询" /> </div> <input type="button" class="btn" id="add_btn" value="新 增" /> <input name="button" type="button" class="btn" id="del_btn" value="删 除" /></div> <table width="49%" cellspacing="1" bgcolor="#0093C4" summary="user infomation table"> <thead> <tr> <th width="4%"><INPUT name="chkAll" id="chkAll" title="全选" onClick="ChkAllClick('skuziduan[]','chkAll')" type="checkbox" /></th> <th width="17%" class="STYLE3">SKU</th> <th width="27%" class="STYLE3">订单SKU</th> <th width="32%" class="STYLE3">FNSKU</th> <th width="20%" class="STYLE3">发货地区</th> </tr> </thead> <tbody> <?PHP while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { ?> <tr> <td><input type="checkbox" name="delivery[]" value="<?PHP echo $row['id']; ?>" /></td> <td><?PHP echo $row['sku'] ?></td> <td><?PHP echo $row['sale_sku'] ?></td> <td><?PHP echo $row['fnsku'] ?></td> <td><?PHP echo $row['delivery_areas'] ?></td> </tr> <?PHP } ?> </tbody> </table></div><div class="digg"><?php echo $pagenav;?></div>
怎么csdn也不稳定 ??
分页源码,这个是我从网上下载的分页类
<?php//为了避免重复包含文件而造成错误,加了判断函数是否存在的条件:@$page = $_GET['page'];if(!function_exists('pageft')){//定义函数pageft(),三个参数的含义为://$totle:信息总数;//$displaypg:每页显示信息数,这里设置为默认是20;//$url:分页导航中的链接,除了加入不同的查询信息“page”外的部分都与这个URL相同。// 默认值本该设为本页URL(即$_SERVER["REQUEST_URI"]),但设置默认值的右边只能为常量,所以该默认值设为空字符串,在函数内部再设置为本页URL。function pageft($totle,$displaypg=20,$shownum=0,$showtext=0,$showselect=0,$showlvtao=7,$url=''){//定义几个全局变量://$page:当前页码;//$firstcount:(数据库)查询的起始项;//$pagenav:页面导航条代码,函数内部并没有将它输出;//$_SERVER:读取本页URL“$_SERVER["REQUEST_URI"]”所必须。global $page,$firstcount,$pagenav,$_SERVER;//为使函数外部可以访问这里的“$displaypg”,将它也设为全局变量。注意一个变量重新定义为全局变量后,原值被覆盖,所以这里给它重新赋值。$GLOBALS["displaypg"]=$displaypg;if(!$page) $page=1;//如果$url使用默认,即空值,则赋值为本页URL:if(!$url){ $url=$_SERVER["REQUEST_URI"];}//URL分析:$parse_url=parse_url($url);$url_query=$parse_url["query"]; //单独取出URL的查询字串if($url_query){//因为URL中可能包含了页码信息,我们要把它去掉,以便加入新的页码信息。//这里用到了正则表达式,请参考“PHP中的正规表达式”$url_query=ereg_replace("(^|&)page=$page","",$url_query);//将处理后的URL的查询字串替换原来的URL的查询字串:$url=str_replace($parse_url["query"],$url_query,$url);//在URL后加page查询信息,但待赋值:if($url_query) $url.="&page"; else $url.="page";}else {$url.="?page";}//页码计算:$lastpg=ceil($totle/$displaypg); //最后页,也是总页数$page=min($lastpg,$page);$prepg=$page-1; //上一页$nextpg=($page==$lastpg ? 0 : $page+1); //下一页$firstcount=($page-1)*$displaypg;//开始分页导航条代码:if ($showtext==1){$pagenav="<span class='disabled'>".($totle?($firstcount+1):0)."-".min($firstcount+$displaypg,$totle)."/$totle 记录</span><span class='disabled'>$page/$lastpg 页</span>";}else{$pagenav=""; }//如果只有一页则跳出函数:if($lastpg<=1) return false;if($prepg) $pagenav.="<a href='$url=1'>首页</a>"; else $pagenav.='<span class="disabled">首页</span>';if($prepg) $pagenav.="<a href='$url=$prepg'>上一页</a>"; else $pagenav.='<span class="disabled">上一页</span>';if ($shownum==1){ $o=$showlvtao;//中间页码表总长度,为奇数 $u=ceil($o/2);//根据$o计算单侧页码宽度$u $f=$page-$u;//根据当前页$currentPage和单侧宽度$u计算出第一页的起始数字 //str_replace('{p}',,$fn)//替换格式 if($f<0){$f=0;}//当第一页小于0时,赋值为0 $n=$lastpg;//总页数,20页 if($n<1){$n=1;}//当总数小于1时,赋值为1 if($page==1){ $pagenav.='<span class="current">1</span>'; }else{ $pagenav.="<a href='$url=1'>1</a>"; } /////////////////////////////////////// for($i=1;$i<=$o;$i++){ if($n<=1){break;}//当总页数为1时 $c=$f+$i;//从第$c开始累加计算 if($i==1 && $c>2){ $pagenav.='...'; } if($c==1){continue;} if($c==$n){break;} if($c==$page){ $pagenav.='<span class="current">'.$page.'</span>'; }else{ $pagenav.="<a href='$url=$c'>$c</a>"; } if($i==$o && $c<$n-1){ $pagenav.='...'; } if($i>$n){break;}//当总页数小于页码表长度时 } if($page==$n && $n!=1){ $pagenav.='<span class="current">'.$n.'</span>'; }else{ $pagenav.="<a href='$url=$n'>$n</a>"; }}if($nextpg) $pagenav.="<a href='$url=$nextpg'>下一页</a>"; else $pagenav.='<span class="disabled">下一页</span>';if($nextpg) $pagenav.="<a href='$url=$lastpg'>尾页</a>"; else $pagenav.='<span class="disabled">尾页</span>';if ($showselect==1){//下拉跳转列表,循环列出所有页码:$pagenav.="跳至<select name='topage' size='1' onchange='window.location=\"$url=\"+this.value'>\n";for($i=1;$i<=$lastpg;$i++){if($i==$page) $pagenav.="<option value='$i' selected>$i</option>\n";else $pagenav.="<option value='$i'>$i</option>\n";}$pagenav.="</select>页";}}}?>
jordan102大大,我源码贴出来了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

Using preprocessing statements and PDO in PHP can effectively prevent SQL injection attacks. 1) Use PDO to connect to the database and set the error mode. 2) Create preprocessing statements through the prepare method and pass data using placeholders and execute methods. 3) Process query results and ensure the security and performance of the code.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.
