一个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-24 12:36:12
-
2025-02-24 12:11:09
-
2025-02-24 12:06:10
-
2025-02-24 12:04:13
-
2025-02-24 12:03:10
-
2025-02-24 12:02:09
-
2025-02-24 12:01:10
-
2025-02-24 12:00:16
-
2025-02-24 11:59:10
-
2025-02-24 11:58:14