Home  >  Article  >  Backend Development  >  PHP实例代码:AJAX 分页显示数据_PHP教程

PHP实例代码:AJAX 分页显示数据_PHP教程

WBOY
WBOYOriginal
2016-07-21 14:56:09886browse

  帮客之家(www.Bkjia.com)教程 PHP实例代码:AJAX 分页显示数据。

调试用的文件

以下为引用的内容:


帮客之家提供教程LIEHUO.NET 关注站长,建设互联网!



PHP实例代码:AJAX 分页显示数据_PHP教程

数据分页显示




  调用的另外一个文件 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{
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]."PHP实例代码:AJAX 分页显示数据_PHP教程
\n";
echo "
echo "border=0>";
echo "
";
echo "
";
echo "

第".$page."页/总".$pages."页 | 总".$numrows."条 | ";
if ($page>1) echo "首页 | ";
if ($page>1) echo "上页 | ";
if ($page下页 | ";
if ($page尾页";
echo " 转到第 ";
echo "

";

?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/364312.htmlTechArticle烈火网(LieHuo.Net)教程 PHP实例代码:AJAX 分页显示数据。 调试用的文件 以下为引用的内容: html head title烈火网提供教程LIEHUO.NET 关注站长,...
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