PHP source code

Source: Internet
Author: User
The phpajax static paging process jumps

Js end and judgment 1? Now-1: 1; break; case 'next': target = now + 1> allpage? Now: 1; break; case 'la': target = allpage> 0? Allpage: 1; break; case 'constans ': target = $ (' # selpage'). val ()> 0? $ ('# Selpage '). val (): 1; default: target = 1 ;} var data = "check =" + act + "& nowpage =" + now + "& perpage =" + per + '& target =' + target; alert (data ); return data;} // execute function goPageFirst () {var param = getData ('first'); http_post (param);} // execute the previous page function goPagePrev () {var param = getData ('prev'); http_post (param);} // run the next page function goPageNext () {var param = getData ('next '); http_post (param);} // execute the last page function goPageLast (){ Var param = getData ('last'); http_post (param);} // select the specified page function goPage () {var param = getData ('constans '); http_post (param);} // post request data loading function http_post (db) {$. post ('. /mysql. php ', db, function (data) {responseAjax (data) ;}, 'text') ;}// call and process the returned data function responseAjax (msg) {// alert (msg); // alert (msg. content); // ('{listdiv'{.html(msg.content}}('{listdiv'{.html (msg);} server end judgment and implementation // @ autor 499188204@qq.commb _ Internal_encoding ('gb2312'); $ con = mysql_connect ("127.0.0.1", "root", "12345678") or die ("connection failed "); $ m = mysql_select_db ("ec", $ con); $ SQL = 'select' attr _ id', 'Cat _ id ', 'attr _ name' FROM 'ecs _ attribute'; $ rs = mysql_query ($ SQL); $ count = mysql_num_rows ($ rs ); // total number of returned Records // echo $ count; // total number of records // 10 records per page // calculate the total number of pages ceil ($ count/10) // echo ''; if (! Isset ($ _ POST ['check']) {$ set ['id'] = 0; die ('No access please! ');} If (isset ($ _ POST ['perpage']) & $ _ POST ['perpage']> 0) {$ per =$ _ POST ['perpage'];} else {$ per = 15;} $ page = ceil ($ count/$ per); // echo $ page; if (! Isset ($ _ POST ['nowpage']) {$ nowpage = 1;} else {$ nowPage =$ _ POST ['nowpage'];} $ start = ($ nowPage-1) * $ per + 1; $ SQL = 'select' attr _ id', 'Cat _ id ', 'attr _ name' from 'ecs _ attribute 'limit '. $ start. ','. $ per; // $ SQL = 'select' attr _ id', 'Cat _ id', 'attr _ name' from 'ecs _ attribute' limit 10 offset 20 '; $ rs = mysql_query ($ SQL); $ str = "attribute ID type number attribute name"; while ($ row = mysql_fetch_assoc ($ rs) {$ str. = ''. $ row ['attr _ id']. ''. $ ro W ['cat _ id']. ''. $ row ['attr _ name']. '';} $ str. = "total ". $ count. "Records are divided ". $ page. "Current page ". $ nowPage. "page, each page | the last page on the first page of the previous page"; for ($ I = 1; $ I ". $ I. "";} else {$ str. = "". $ I. "" ;}}$ str. = ""; echo mb_convert_encoding ($ str, 'utf-8', 'gb2312 '); // $ set ['content'] = $ str; // echo json_encode ($ set);?>. Code_report {float: right }. code_report p {float: left; margin-left: 5px; background: url ("/img/ask-icon.gif") no-repeat; padding: 6px 0 6px 15px; padding-left: 15px; height: 16px ;}. code_report a {background: url ("/img/ask-icon.gif") 0-160px no-repeat; padding-left: 20px; line-height: 15px; height: 16px; color: #333; text-decoration: none; display: inline-block; zoom: 1; vertical-align: middle ;}. code_report em {height: 28px; line-height: 28px; width: 14px; display: inline-block; float: left; background: url ("/img/ask-icon.gif ") top right;} "_ ue_custom_node _ =" true ">

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.