php 分页

public function rangeIndex(){
	    $start= explode(".",$_GET['startIp']);
		$startIp=$start[count($start)-1];
		
		$stop= explode(".",$_GET['stopIp']);
		$stopIp=$stop[count($stop)-1];
		
		$range= explode(".",$_GET['stopIp']);
		$rangIp=$range[count($stop)-2];
		import('ORG.Util.Page');//导入分页类
		//$m=M("Machine_info");
		$m=M();
		//$where[substring_index("ip",'.',-1)] = array(array('gt',$startIp),array('lt',$stopIp));
		$countNum = $m->query("select count(*) from machine_info where substring_index(ip,'.',-1)>$startIp  and substring_index(ip,'.',-1)<$stopIp and  substring_index(substring_index(ip,'.',-2),'.',1) =$rangIp");
		//$count = $m->where($where)->select();
		
		$count = (int)$countNum[0]["count(*)"];
		$page=new Page($count,15);//实例化分页类 传入总记录数和每页显示的记录数
		$show=$page->show();//分页显示输出
		
		
		$result=$m->query("select * from machine_info  where substring_index(ip,'.',-1)>$startIp  and substring_index(ip,'.',-1)<$stopIp and  substring_index(substring_index(ip,'.',-2),'.',1) =$rangIp limit ".$page->firstRow.",".$page->listRows);
		//$result = $m->where($where)->limit($page->firstRow.','.$page->listRows)->select();
		$this->assign('result',$result);
		$this->assign('show',$show);
		$this->assign('startIp',$_GET['startIp']);
		$this->assign('stopIp',$_GET['stopIp']);
		$this->display();
	}

原文地址:https://www.cnblogs.com/hzcya1995/p/13350111.html