封装的类:
写在php页面里面的代码:
-
-
- 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);
- ?>
-
复制代码
来自:http://blog.csdn.net/phpfenghuo/article/details/23207099
|
分页, php, mysql
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31