Loading information, first remove 5 pages from the database to implement paging, the mouse swipe up to trigger Ajax Reload 5, to achieve asynchronous refresh, optimized loading ...

Source: Internet
Author: User
Tags php database

PHP Database Fetch data

<?PHP include ("conn1.php"); Include ('.. /function/functions.php'); $page=intval ($_get['page']); $page= $page = =0?1: $page; $page _size=5; $limit= ($page-1) * $page _size).",". $page _size; $sql="Select *from v9_news where catid=182 and status=99 order by inputtime desc limit $limit"; $result=mysqli_query ($link, $sql); $arr=Array (); $item=Array ();  while($row =Mysqli_fetch_assoc ($result)) {$row ['Inputtime']= Date ('m-d', $row ['Inputtime']); $row ['UpdateTime']= Date ('m-d', $row ['UpdateTime']); $arr []=$row; } $item ['page']=$page; $item ['Item']=$arr; $json=Json_encode ($item, Json_unescaped_unicode);        Echo $json; 

jquery and Ajax for sliding request loading

  functionOnload1 (url,a) {$.ajax ({type:"Get", Url:url, DataType:"JSON", Data: {page:0,}, Success:function(data) {$ (a). HTML (makehtml0 (data)); }, Error:function(i) {alert ("Network Error");                 }                        }); }   functionscroll1 (URL) {varpage=2; varOld=0; varA=true;//function of Switch timer//Swipe down$ ("#item1mobile"). Scroll (function() {                var$ This= $( This), Viewh= $( This). Height (),//Visible Height 312Contenth = $ ( This). Get (0). ScrollHeight,//Content Height 422ScrollTop = $ ( This). ScrollTop ();//scrolling Height                if(ScrollTop >Old ) {                    if(ScrollTop/(CONTENTH-VIEWH) >= 0.80) {//when you reach bottom 90%, load new content                        if(a) {$.ajax ({type:"Get", Url:url, DataType:"JSON", data: {page:page,}, Success:function(data) {$ (' #item1mobile '). Append (makehtml0 (data)); Page=data.page+1; A=true; }, Error:function(i) {alert ("Network Error"); A=true;                    }                        }); } A=false; }            }                //Slide UpOld =scrolltop}); }     varMakehtml0 =function(data) {varhtml = ' ';  for(vari = 0; i < data.item.length; i++) {HTML+ = "<div class= ' Row ' >" + "<a href= ' detail/legaldetail.php?id=" +data.item[i].id+ ' > ' + ' <div class= ' col-xs-12 content ' > ' + ' <div class= ' col-xs-12 title ' > ' +data.item[i].titl E+ "</div>" + "<div class= ' col-xs-4 date ' >" +data.item[i].inputtime+ "</div>" + "</div>" + "</a>" + "</div>" + "<div class= ' fenge111 ' >" + "</div>"; }            returnhtml; };

HTML page

 <DivID= "Item1mobile"class= "Mui-slider-item mui-control-content mui-active">             </Div><Scriptsrc= "./js/jquery.js"></Script><Scripttype= "Text/javascript">Onload1 ('http://www.zbgh.org.cn/appUnion/data/legal-data-1.php','#item1mobile'); SCROLL1 ('http://www.zbgh.org.cn/appUnion/data/legal-data-1.php');</Script>

Loading information, first remove 5 pages from the database to implement paging, the mouse swipe up to trigger Ajax Reload 5, to achieve asynchronous refresh, optimized loading ...

Related Article

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.