Copy code The code is as follows: js end and judgment <br>$(function(){ <br>//var url=$(this)[0].location. href; <br>//alert(url); <br>goPageFirst(); <br>$('#selpage').bind('change',goPage); <br>}); <br>// Return the current page number<br>function getNowPage() <br>{ <br>return parseInt($('#nowPage').html()); <br>} <br>//Return the number of items displayed on each page <br>function getPer() <br>{ <br>return $('#perPage').val(); <br>} <br>//Return the total number of records <br>function getTotal() <br> { <br>return parseInt($('#total').html()); <br>} <br>//Return the total number of pages <br>function getAllPage() <br>{ <br>return parseInt( $('#allpage').html()); <br>} <br>//Combined string parameters<br>function getData(act) <br>{ <br>var target=1; <br>var now=getNowPage()+1; <br>var per=getPer(); <br>var sum=getTotal(); <br>var allpage=getAllPage(); <br>switch(act) <br>{ <br>case 'first': <br>target=1; <br>break; <br>case 'prev': <br>target=now>1?now-1:1; <br>break; <br> case 'next': <br>target=now+1>allpage?now:1; <br>break; <br>case 'last': <br>target=allpage>0?allpage:1; <br>break ; <br>case 'consstans': <br>target=$('#selpage').val()>0?$('#selpage').val():1; <br>default : <br>target=1; <br>} <br>var data="check="+act+"&nowpage="+now+"&perpage="+per+'&target='+target; <br>alert(data); <br>return data; <br>} <br>//Execute the first page<br>function goPageFirst() <br>{ <br>var param=getData('first'); <br>http_post(param); <br>} <br>//Execute the previous page<br>function goPagePrev() <br>{ <br>var param=getData('prev'); <br>http_post(param); <br>} <br>//Execute the next page<br>function goPageNext() <br>{ <br>var param=getData('next'); <br>http_post(param); <br>} <br>//Execute the last Page<br>function goPageLast() <br>{ <br>var param=getData('last'); <br>http_post(param); <br>} <br>//Select to the specified page<br>function goPage() <br>{ <br>var param=getData('constans'); <br>http_post(param); <br>} <br>//post request data loading <br>function http_post(db) <br>{ <br>$.post('./mysql.php',db,function(data){ <br>responseAjax(data); <br>},'text'); <br>} <br> //Return data processing<br>function responseAjax(msg) <br>{ <br>//alert(msg); <br>//alert(msg.content); <br>//$('# listDiv').html(msg.content); <br>$('#listDiv').html(msg); <br>} <br>Server-side judgment and implementation<br>//@autor 499188204@qq. com <br>mb_internal_encoding('gb2312'); <br>$con=mysql_connect("127.0.0.1","root","12345678") or die("Connection failed"); <br>$m=mysql_select_db( "ec",$con); <br>$sql = 'SELECT `attr_id`,`cat_id`,`attr_name` <br>FROM `ecs_attribute` '; <br>$rs = mysql_query($sql ); <br>$count = mysql_num_rows($rs); //Return the total number of records<br>//echo $count; //The total number of records<br>//The number of records per page 10 <br>//Find the total number of pages ceil ($count/10) <br>//echo '<hr >'; <br>if(!isset($_POST['check'])) <br>{ <br>$set['id' ]=0; <br>die('no access please!'); <br>} <br>if(isset($_POST['perpage']) && $_POST['perpage']>0 ) <br>{ <br>$per=$_POST['perpage']; <br>} <br>else <br>{ <br>$per=15; <br>} <br>$page = ceil($count /$per); <br>//echo $page; <br>if(!isset($_POST['nowpage'])) <br>{ <br>$nowPage=1; <br>} <br> else <br>{ <br>$nowPage = $_POST['nowpage']; <br>} <br>$start = ($nowPage-1)*$per+1; <br>$sql = 'select ` attr_id`,`cat_id`,`attr_name` from `ecs_attribute` limit '.$start.','. $per; <br>//$sql = 'select `attr_id`,`cat_id`,`attr_name` from ` ecs_attribute` limit 10 offset 20'; <br>$rs = mysql_query($sql ); <br><br>$str = "<table id='content'> <br><tr><th> ;Attribute number</th><th>Type number</th><th>Attribute name</th></tr>"; <br>while($row = mysql_fetch_assoc($rs) ){ <br>$str .='<tr><td>'.$row['attr_id'].'</td><td>'.$row['cat_id'].'< ;/td><td>'.$row['attr_name'].'</td><tr>'; <br>} <br>$str.="</table> <br> <table id='page_list'> <br><tr><td><div><span>Total<span id='total'>".$count."</span> ;The records are divided into<span id='allpage'>".$page."</span>The current page of page<span id='nowPage'>".$nowPage."</span> Page, per page<input type='text' id='perPage' value='".$per."'/> | <br><a href='javascript:void(0)' onclick=' goPageFirst()'>First page</a> <br><a href='javascript:void(0)' onclick='goPagePrev()'>Previous page</a> <br> <a href='javascript:void(0)' onclick='goPageFirst()'>Next page</a> <br><a href='javascript:void(0)' onclick='goPageFirst ()'>Last page</a> <br><select id='selpage' >"; <br>for($i=1;$i <=$page;$i++) <BR>{ <BR>if($nowPage==$i) <BR>{ <BR>$str .= "<option selected >".$i."</option>"; <br>}<br>else <br>{ <br>$str .= "<option >".$i."</option>"; <br>} <br>} <br>$str .="</select> <br></span></div></td></tr> <br></table>"; <br>echo mb_convert_encoding($str,'UTF-8','gb2312'); <br>//$set['content']=$str; <br>//echo json_encode($set); <br>?> <br> </div> <p align="left"></p> <div style="display:none;"> <span id="url" itemprop="url">http://www.bkjia.com/PHPjc/324309.html</span><span id="indexUrl" itemprop="indexUrl">www.bkjia.com</span><span id="isOriginal" itemprop="isOriginal">true</span><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http://www.bkjia.com/PHPjc/324309.html</span><span id="genre" itemprop="genre">TechArticle</span><span id="description" itemprop="description">复制代码 代码如下: js 端 及判断 script language='javascript' $(function(){ //var url=$(this)[0].location.href; //alert(url); goPageFirst(); $('#selpage').bind('change',...</span> </div> <div class="art_confoot"></div>