Home >Backend Development >PHP Tutorial >php ajax pagination four_PHP tutorial

php ajax pagination four_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:05:591072browse

ajax paging php ajax paging java ajax paging asp.net ajax paging jquery ajax paging jsp ajax no refresh paging asp ajax paging ajax paging problem ajax implementation paging ajax jsp paging
The most important thing is the result.php file of php,:

//A series of queries from the database will not be described here... You can know it by referring to the following
//PHP server
/*
PHP paging function
function Ajaxpage($sql,$num){
global $db;
$pageno=$_GET['pageno '];
$pageno=(int)$pageno;
if(empty($pageno)||$pageno<1) $pageno=1;
$result=$db->query( $sql);
$number=$db->num_rows($result);
$totalpage=(int)ceil($number/$num);
if($pageno>=$totalpage ){$pageno=$totalpage;}
$start_rowno=($pageno-1)*$num;
$query=$sql." LIMIT ".$start_rowno.",".$num;
$result=$db->query($query);
return array('result'=>$result,'page'=>array('pageno'=>$pageno,'totalpage' =>$totalpage,'number'=>$number));
}

$sql="select * from guest";//Query SQL statement
$num=2; //Paging control, display 2 records per page
$return=Ajaxpage($sql,$num);
while($row=$db->fetch_assoc($return['result'])) {
$result[]=$row; //You can use PHP to process the data here, but I won’t give an example here
}
$result=array('result'=>$result,'page '=>$return['page']);
include('json.class.php');//Include JSON class file
$json=& new Json();
$result =$json->encode($result);//JSON
echo $result;
*/
//If the pageno parameter is sent through AJAX and the resource obtained from the database is $str after JSON Like this, output directly and let JS process it.
//If you don’t understand anything, you can ask me
if(ob_get_length()) ob_clean();
header('cache-control:no-cache ,must-revalidate');
header('pragma:no-cache');
if($_GET['pageno']==1)
$str='{"result":[ {"id":"99","name":"technology","qq":"","tel":"","email":"","content":"[emot:0]", "time":"1198522490","ip":"127.0.0.1",

"rcontent":null,"rtime":"0","url":"0 ","img":"app/index/image/show/1.gif"},{"id":"100","name":"Test","qq":"","tel":" ","email":"","content":"[emot:9]","time":1198548687","ip":"127.0.0.1","

rcontent":null,"rtime":"0","url":"0","img":"app/index/image/show/4.gif"}],"page":{"pageno" :1,"totalpage":2,"number":2}}';
else
$str='{"result":[{"id":"101","name":"Ah ","qq":"","tel":"","email":"","content":"[emot:8][emot:1]","time":"1198548716","ip ":"127.0.0.1","rcontent":null,"rtime":"0","url":"0","img":

"app/index /image/show/9.gif"}],"page":{"pageno":2,"totalpage":2,"number":3}}';

echo iconv('gb2312' ,'utf-8',$str);
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445074.htmlTechArticleajax paging php ajax paging java ajax paging asp.net ajax paging jquery ajax paging jsp ajax no refresh paging asp ajax paging ajax paging problem ajax paging ajax jsp paging is the most p...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn