复选框,如果我想对选择的数据进行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大大,我源码贴出来了

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


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

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use
