PHP執行個體代碼:AJAX 分頁顯示資料_PHP教程

來源:互聯網
上載者:User
  幫客之家(www.Bkjia.com)教程 PHP執行個體代碼:AJAX 分頁顯示資料。

調試用的檔案

以下為引用的內容:


幫客之家提供教程LIEHUO.NET 關注站長,建設互連網!




資料分頁顯示




  調用的另外一個檔案 Example8_7_1.php

以下為引用的內容:
header("Content-Type:text/html;charset=GB2312");
$pagesize=10;
//echo $_POST['page'];
$db=mysql_connect("localhost","root",""); //建立資料庫連接
mysql_query("set character set utf-8");
mysql_select_db("optics");
$result = mysql_query("Select count(DISTINCT articleid) FROM product");
$myrow = mysql_fetch_array($result);
$numrows=$myrow[0];
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
$pages++;
if (isset($_POST['page'])){
$page=intval($_POST['page']);
}
else{
//設定為第一頁
$page=1;
}
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
//計算記錄位移量
$offset=$pagesize*($page - 1);
//讀取指定記錄數

//$result=mysql_query("select `id` , count( * ) from ".book." GROUP BY `id` order by id desc limit $offset,$pagesize");
$result=mysql_query("select * from product GROUP BY `articleid` order by articleid desc limit $offset,$pagesize");
$num = @mysql_num_rows($result);

while ($row = @mysql_fetch_array($result,MYSQL_NUM)) {
$hotelname[] = $row[0];
$name[]=$row[1];
$author[]=$row[2];
$publisher[]=$row[3];
$isbn[]=$row[4];
$type[]=$row[5];
$smallpic[]=$row[6];
//$countpeople[] = $row[1];
}
echo "














\n"; echo " \n"; echo " "; for($a=0;$a<$num;$a++) { echo " \n"; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; } echo "
ID編號 名稱 作者 出版社 ISBN號 類型 價格
".$hotelname[$a]."".$name[$a]."".$author[$a]."".$publisher[$a]."".$isbn[$a]."".$type[$a]."
\n";
echo "
echo "border=0>";
echo "
";
echo "";
echo "

第".$page."頁/總".$pages."頁 | 總".$numrows."條 | ";
if ($page>1) echo "首頁 | ";
if ($page>1) echo "上頁 | ";
if ($page<$pages) echo "下頁 | ";
if ($page<$pages) echo "尾頁";
echo " 轉到第 頁 ";
echo "

";

?>

http://www.bkjia.com/PHPjc/364312.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/364312.htmlTechArticle烈火網(LieHuo.Net)教程 PHP執行個體代碼:AJAX 分頁顯示資料。 調試用的檔案 以下為引用的內容: html head title烈火網提供教程LIEHUO.NET 關注站長,...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.