编码器中的分页404错误


Pagination in codeigniter 404 error

控制器文件:函数索引在这里

      public function index()
      {
        $this->load->helper('url');
        $this->load->helper('form');
        $this->load->model('register_model');
        $this->load->library("pagination");
        $config = array();
        $config["base_url"] = base_url()."register";
        $config["total_rows"] = $this->register_model->record_count();
        $config["per_page"] = 5;
        $config["uri_segment"] = 3;
        $this->pagination->initialize($config);
        $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
        $data["result"] = $this->register_model->fetch_logs($config["per_page"], $page);
        $data["links"] = $this->pagination->create_links();            
        $this->load->view('register',$data);            
      }

这是我的模型函数

     public function view()
     {
      $query = $this->db->query("select * from user_login");
       return $query->result_array();
      }
    public function record_count() 
    {
       return $this->db->count_all("user_login");
    }
    public function fetch_logs($limit, $start) 
    {
       $this->db->limit($limit, $start);
       $query = $this->db->get("user_login");
       if ($query->num_rows() > 0) {
           foreach ($query->result() as $row) {
              $data[] = $row;
           }
           return $data;
        }
        return false;
      }

这是我的视图代码

    <form method="post" accept-charset="utf-8" action="<?php echo base_url(); ?>/register/create" class="myform" id="myform" />
    <div style="text-align:left;"><h1>User Registration</h1></div>
        <table width="488" border="0">
          <tr>
            <td colspan="3">User
              <input name="user_name" type="text" size="40" /></td>
          </tr>
          <tr>
            <td colspan="3">Pass
              <input name="password" type="password" size="40" /></td>
          </tr>
          <tr>
            <td width="278" align="right"><input name="submit" type="submit" value="ADD"  class="big_btn"/></td>
            <td width="148" align="center">&nbsp;</td>
            <td width="48" align="center">&nbsp;</td>
          </tr>
      </table>
        <p>&nbsp;</p>
            <table width="679" border="1" cellpadding="3" cellspacing="0">
        <tr><th width="202" align="center">User</th>    
          <th width="319" align="center">Password</th>
          <th colspan="2" align="center">Action</th>
        <?php 
        foreach ($result as $row)
      {
      ?>
      <tr>
      <td height="32" align="center"><?php echo $row->user;?>   </td>
      <td align="center"><?php echo md5($row->pwd);?></td>
      <td width="56" align="center"><a href="<?php echo base_url();?>/register/delete/<?php echo $row->id;?>">
       <input name="delete" type="button" id="delete" value="x" class="del_btn">
      </a></td>
      <td width="68" align="center"><?php 
    $atts = array(
                  'width'      => '700',
                  'height'     => '300',
                  'scrollbars' => 'no',
                  'status'     => 'no',
                  'resizable'  => 'yes',
                  'screenx'    => '600',
                  'screeny'    => '150'
                );
    echo anchor_popup(base_url().'/register/viewmore/'.$row->id, '<input name="view" type="button" id="view" value="" class="view_btn">', $atts);
    ?></td>
      </tr>
    <?php  
      }
        ?>
      </table>
    </form>
    </div>   <p><?php echo $links; ?></p>  

在这里我可以看到分页链接,但在我点击链接后,它给出404页未找到错误有人能检查一下并回复吗??

如果你的上面的控制器是寄存器控制器,那么你可以使用

  $config["base_url"] = site_url("register"); //this will call the index function of register contoller

修改

$config["base_url"] = base_url()."register";

$config["base_url"] = base_url('register'); // or you can use site_url('register');
public function index() {
    $this->load->helper ( 'url' );
    $this->load->helper ( 'form' );
    $this->load->model ( 'register_model' );
    $this->load->library ( "pagination" );
    $config = array ();
    $config ["base_url"] = base_url ( 'register/index/' );
    $config ["total_rows"] = $this->register_model->record_count ();
    $config ["per_page"] = 5;
    $config ["uri_segment"] = 3;
    $this->pagination->initialize ( $config );
    $page = ($this->uri->segment ( 3 )) ? $this->uri->segment ( 3 ) : 0;
    $data ["result"] = $this->register_model->fetch_logs ( $config ["per_page"], $page );
    $data ["links"] = $this->pagination->create_links ();
    $this->load->view ( 'register', $data );
}

我想这就是问题所在像

$config['base_url'] = site_url('register/index/');