一个php+mysql分页类代码
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
發布: 2016-07-25 08:52:47
分页类用法:
-
-
-
-
include_once("fenye_php.php"); //引入类
- ///////////////////////////////////////////////////////////////////////
- $con = mysql_connect("localhost","root","");
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
mysql_select_db("myblog", $con);//选取数据库
-
- $PAGE_SIZE=10;//设置每页显示的数目
- ///////////////////////////////////////////////////////////////////////
- $pageSupport = new PageSupport($PAGE_SIZE); //实例化PageSupport对象
- $current_page=$_GET["current_page"];//分页当前页数
- if (isset($current_page)) {
- $pageSupport->__set("current_page",$current_page);
- } else {
- $pageSupport->__set("current_page",1);
- }
-
- $pageSupport->__set("sql","select * from article ");
- $pageSupport->read_data();//读数据
-
- if ($pageSupport->current_records > 0) //如果数据不为空,则组装数据
- {
- for ($i=0; $icurrent_records; $i++)
- {
- $title = $pageSupport->result[$i]["title"];
- $content = $pageSupport->result[$i]["content"];
-
- $part=substr($content,0,400);
- //循环输出每条数据
- echo '';
- }
- }
- $pageSupport->standard_navigate(); //调用类里面的这个函数,显示出分页HTML
- //关闭数据库
- mysql_close($con);
- ?>
-
-
复制代码
|
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11
最新問題
-
2025-03-26 19:48:00
-
2025-03-26 19:40:08
-
2025-03-26 12:24:37
-
2025-03-26 12:20:46
-
2025-03-21 13:39:34