To be or not to be.That is a question!

---源于莎士比亚的《哈姆雷特》

导航

< 2025年6月 >
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 1 2 3 4 5
6 7 8 9 10 11 12

统计

codeigniter 分页类练习

controller page页:

复制代码
<?php
    class Blog extends CI_Controller{
        public function __construct(){
            parent::__construct();
            $this->load->library("table");
            $this->load->library("pagination");
        }
        public function index(){
            $config['base_url']='http://127.0.0.1/CI/index.php/blog/index';
            $config['total_rows']=$this->db->get("CI_tb")->num_rows();
            $config['per_page']=5;
            $config['num_links']=15;
            $this->pagination->initialize($config);
            // $this->load->model("blogs");
            $data['results']=$this->db->get("CI_tb",$config['per_page'],$this->uri->segment(3));
            $this->load->view("blogs",$data);
        }

    }
?>
复制代码

view page页:

复制代码
<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <h1>This is test file!</h1>
    <?php echo $this->table->generate($results); ?>
    <?php echo $this->pagination->create_links(); ?>
</body>
</html>
复制代码

 

posted on 2013-08-12 16:12  Ijavascript  阅读(289)  评论(0)    收藏  举报

编辑推荐:
· 编码之道,道心破碎。
· 记一次 .NET 某发证机系统 崩溃分析
· 微服务架构学习与思考:SOA架构与微服务架构对比分析
· tomcat为什么假死了
· 聊一聊 Linux 上对函数进行 hook 的两种方式
阅读排行:
· 一周 Star 破万的开源项目「GitHub 热点速览」
· 编码之道,道心破碎。
· 千万级大表,如何做性能调优?
· 不写代码,让 AI 生成手机 APP!保姆级教程
· 知名开源项目Alist被收购!惹程序员众怒,开团炮轰甲方
点击右上角即可分享
微信分享提示