Php 使用sql和html表在Codeigniter中分页

Php 使用sql和html表在Codeigniter中分页,php,codeigniter,pagination,Php,Codeigniter,Pagination,我有一个包含html表的视图,该表显示从数据库检索的数据。有可能为它进行分页吗 视图的代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <div class="row" ng-

我有一个包含html表的视图,该表显示从数据库检索的数据。有可能为它进行分页吗

视图的代码

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>

    <body>
        <div class="row" ng-app="appcolor">
            <div class="col-lg-12">
                <!-- Section for tabs-->
                <div class="tabbable">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#home_banner" data-toggle="tab">Home Banner</a></li>
                    </ul>
                </div>

            <!-- Section for tab content-->
            <div class="tab-content">
                <div class="tab-pane active" id="home_banner">
                    <fieldset>
                        <!-- Section for managing home banner -->
                        <legend>Manage Home Banner</legend>
                            <?php if($this->session->flashdata('notification')) {echo '<div class="alert alert-success">'.$this->session->flashdata('notification').'</div>'; } ?>
                            <?php if($banners != NULL) { ?>
                            <form action="<?php echo base_url().'backendBanner/update_banners'; ?>" method="POST">
                                <table style="" class="table table-striped">
                                    <tr>
                                        <th>Banner Image</th>
                                        <th>Title</th>
                                        <th>Description</th>
                                        <th>Is Active</th>
                                        <th>Seq Num</th>
                                        <th>Viewed By</th>
                                        <th>Link</th> 
                                        <th>Mobile Link</th> 
                                        <th>Delete</th>
                                    </tr>
                            <?php } ?>
                            <?php foreach($banners as $banner) { ?>
                                    <tr>
                                        <input type="hidden" name="banner_path[]" value="<?php echo $banner['banner_path']; ?>">
                                        <!-- Display the banner image -->
                                        <td style="width:170px;"><?php echo "<img style='width:150px; height:100px'class='gc_thumbnail' src='".base_url()."../home_banner_images/".$banner['banner_path']."' style='padding:5px; border:1px solid #ddd'/>"; ?></td>
                                        <!-- Display the banner title -->
                                        <td style="width:170px;">
                                            <input name="banner_title[]" type="text" value="<?php echo $banner['banner_title']; ?>" style="width:180px;">
                                        </td>
                                        <!-- Display the banner desc -->
                                        <td style="width:170px;">
                                            <input name="banner_desc[]" type="text" value="<?php echo $banner['banner_desc']; ?>" style="width:180px;">
                                        </td>
                                        <!-- Drop down list to select whether the banner is active -->
                                        <td style="width:60px;">
                                            <select name="is_active[]" style="width:60px;">
                                            <?php 
                                                echo "<option value='0'"; if($banner['is_active'] == 0) {echo "selected";}; echo ">".'0'."</option>";
                                                echo "<option value='1'"; if($banner['is_active'] == 1) {echo "selected";}; echo ">".'1'."</option>";
                                                echo "</select>"; 
                                            ?>
                                        </td>
                                        <!-- Drop down list to select the sequence number -->
                                        <td style="width:75px;">
                                            <?php echo '<select name="seq[]" style="width:60px;">'; 
                                                for($count =1 ; $count <= count($banners); $count ++)
                                                { 
                                                    echo "<option value='$count'"; if($banner['seq'] == $count) {echo "selected";}; echo ">".$count."</option>";
                                                }
                                            ?>
                                            </select>
                                        </td>
                                        <!-- Drop down list to select the banner can be view by which group of users-->
                                        <td style="width:130px;">
                                            <select name="viewed_by[]" style="width:120px;">
                                            <?php 
                                                echo "<option value='members'"; if($banner['viewed_by'] == 'members') { echo "selected"; } echo ">".'Members'."</option>";
                                                echo "<option value='non-members'"; if($banner['viewed_by'] == 'non-members') { echo "selected"; } echo ">".'Non-Members'."</option>";
                                                echo "<option value='both'"; if($banner['viewed_by'] == 'both') { echo "selected"; } echo ">".'Both'."</option>";
                                                echo "</select>"; ?>
                                        </td>
                                        <!-- Text field for user to input the banner url link -->
                                        <td style="width:230px;">
                                            <input name="url[]" type="text" value="<?php echo $banner['url']; ?>" style="width:180px;">
                                        </td>
                                        <!-- Text field for user to input the banner mobile url link -->
                                        <td style="width:230px;">
                                            <input name="murl[]" type="text" value="<?php echo $banner['murl']; ?>" style="width:180px;">
                                        </td>
                                      </tr>
                            <?php } ?>
                            <?php if($banners != NULL) { ?>
                                </table>
                    </fieldset>
                </div>
    </body>
</html>
模型的代码

class backend_banner_model extends CI_Model {

    public function __construct ()
    {
        parent::__construct();
        $this->db = $this->load->database('online', TRUE);
    }

    //Section for home banner (category)
    /* Get the list of banner from the category of "home_banner */
    public function get_landing_banners()
    {
        $this->db->select('*')->from('banner')->where('banner_category', 'home_banner');
        $data = $this->db->get();
        if ($data->num_rows() > 0) {
        return $data->result_array();
        }
    }
}

您不了解分页文档的哪一部分?我不确定如何使用从控制器到模型再到视图的分页。您阅读文档了吗?
class backend_banner_model extends CI_Model {

    public function __construct ()
    {
        parent::__construct();
        $this->db = $this->load->database('online', TRUE);
    }

    //Section for home banner (category)
    /* Get the list of banner from the category of "home_banner */
    public function get_landing_banners()
    {
        $this->db->select('*')->from('banner')->where('banner_category', 'home_banner');
        $data = $this->db->get();
        if ($data->num_rows() > 0) {
        return $data->result_array();
        }
    }
}