请问分页类显示的页码怎么加入查询的条件,现在查询出来的页码链接都没有加上查询条件的
php分页类源码
<?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>页";}}}?>
回复讨论(解决方案)
很不错。收藏先
最近回复老是提示出错
楼主贴的代码貌似不完全呀,查询条件估计在另外的其它代码,只是想要一个分页类,我可以提供,如有需要可以私信与我。
<h2 id="销售订单列表">销售订单列表</h2><form id="add_form" action="sale_list.php?page=1" method="post"><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;if(!empty($_POST['findtext'])){$findtext=$_POST['findtext'];$findtype=$_POST['findtype'];$findsql="AND `".$findtype."`='".$findtext."'";$findpage=$findtype."=".$findtext;}else{$findsql='';$findpage='';}$result = mysql_query("SELECT COUNT(*) AS count FROM `sale_orders` WHERE `number`>0 ".$findsql); $row = mysql_fetch_array($result, MYSQL_ASSOC); $total= $row['count'];$SQL = "SELECT * FROM `sale_orders` WHERE `number`>0 ".$findsql." LIMIT $start , $pageSize";$result = mysql_query($SQL); pageft($total,$pageSize,1,1,1,5);?><div id="opt"> <div id="query"> <label></label> <select name="findtype"> <option value="order_id" selected="selected" >订单号</option> <option value="sku" >订单SKU</option> </select> <input type="text" class="input" id="sale_text" name="findtext" /> <input type="submit" class="btn" id="find_btn" value="查 询" /> </div> </div> <table width="195%" cellspacing="1" bgcolor="#0093C4" summary="user infomation table"> <thead> <tr> <th width="17%"><span class="STYLE3">订单号</span></th> <th width="11%" class="STYLE3">客户姓名</th> <th width="17%" class="STYLE3">订单SKU</th> <th width="42%" class="STYLE3">产品名称</th> <th width="6%" class="STYLE3">购买数量</th> <th width="7%" class="STYLE3">订单状态</th> </tr> </thead> <tbody> <?PHP while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { ?> <tr> <td><?PHP echo $row['order_id'] ?></td> <td><?PHP echo $row['buyer_name'] ?></td> <td><?PHP echo $row['sku'] ?></td> <td><?PHP echo $row['product_name'] ?></td> <td><?PHP echo $row['quantity_purchased'] ?></td> <td><?PHP $shipments=$row['shipments']; switch ($shipments){case "0": echo "未发货"; break;case "1": echo "已发货"; break; case "2": echo "已取消"; break;} ?></td> </tr> <?PHP } ?> </tbody> </table></div></form><div class="digg"><?php echo $pagenav;?></div>
我贴代码老是提示出错,经常贴不上来,这个分页类现在能分页,就是分页按钮链接里面没有查询条件,我想请问怎么把查询条件也加入到链接里面
怎么添加查询条件??
他不是有个 $url 参数吗?
就是做这个用的
怎么添加查询条件??

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

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-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

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' =>

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.

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

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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.

Dreamweaver CS6
Visual web development tools

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