程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php ajax 分頁四

php ajax 分頁四

編輯:關於PHP編程

ajax分頁  php ajax 分頁   java ajax分頁   asp.net ajax分頁   jquery ajax 分頁 jsp ajax無刷新分頁   asp ajax分頁   ajax 分頁問題   ajax實現分頁   ajax jsp分頁
最就是php的result.php文件喽,:

<?php
//一系列從數據庫的查詢造作這裡就不多說了....自己參考以下就知道了
//PHP服務端
/*
PHP分頁函數
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";//查詢SQL語句
$num=2;//分頁控制,每頁顯示2條記錄
$return=Ajaxpage($sql,$num);
while($row=$db->fetch_assoc($return['result'])){
 $result[]=$row; //這裡可以用PHP處理下數據,這裡就不舉例了
}
$result=array('result'=>$result,'page'=>$return['page']);
include('json.class.php');//包含JSON類文件
$json=& new Json();
$result=$json->encode($result);//JSON
echo $result;
*/
//假如根據AJAX發來pageno參數從數據庫得到的資源經過JSON後是$str這個樣子,直接輸出,讓JS處理.
//如果有什麼不明白的可以問我
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":"技術","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":"測試","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":"啊","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);
?>


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved