如何解决codeigniter中的分页问题
我不想在我的项目中创建分页,但我有一些问题。如何解决codeigniter中的分页问题,codeigniter,Codeigniter,我不想在我的项目中创建分页,但我有一些问题。 我正在CodeIgniter中使用.htaccess。它使我的url不使用index.php 然后我在控制器中创建了分页规则:$config['base\u url']='http://localhost/project/member“” 它使我的项目无法使用分页,但是如果我使用$config['base\u url']='http://localhost/project/member/index“,分页工作正常。 情况是我的页面无法显示css程序,
我正在CodeIgniter中使用
.htaccess
。它使我的url不使用index.php
然后我在控制器中创建了分页规则:$config['base\u url']='http://localhost/project/member“
”它使我的项目无法使用分页,但是如果我使用
$config['base\u url']='http://localhost/project/member/index“
,分页工作正常。情况是我的页面无法显示css程序,因为我使用的是引导程序。在这种情况下,当我在
基本url中使用“index”而不使用“index”时,如何解决这个问题?使用下面的代码,它会起作用
$this->load->library("pagination");
$config = array();
$config["base_url"] = base_url() . "review";
$config["total_rows"] = $this->blog->getReviewCount();
$config["per_page"] = 10;
$config["uri_segment"] = 2;
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['prev_link'] = 'Previous';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = 'Next';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$data['title'] = "Review";
$data["links"] = $this->pagination->create_links();
$data['review'] = $this->blog->getReviews($config["per_page"], $page);
$this->load->view("review", $data);
$this->load->library(“分页”);
$config=array();
$config[“基本url”]=基本url()。“审查”;
$config[“总计行数”]=$this->blog->getReviewCount();
$config[“每页”]=10;
$config[“uri_段”]=2;
$config['full_tag_open']=“”;
$config['full_tag_close']='
';
$config['num_tag_open']='';
$config['num_tag_close']=' ;
$config['cur_tag_open']=';
$config['prev_tag_open']='';
$config['prev_tag_close']=' ;
$config['first_tag_open']='';
$config['first_tag_close']=' ;
$config['last_tag_open']='';
$config['last_tag_close']=' ;
$config['prev_link']='Previous';
$config['prev_tag_open']='';
$config['prev_tag_close']=' ;
$config['next_link']='next';
$config['next_tag_open']='';
$config['next_tag_close']=' ;
$this->pagination->initialize($config);
$page=($this->uri->segment(2))$此->uri->段(2):0;
$data['title']=“审查”;
$data[“links”]=$this->pagination->create_links();
$data['review']=$this->blog->getReviews($config[“每页”],$page);
$this->load->view(“查看”,$data);
@Lin当您从$config[base\u url]中取出index.php时,您需要在根文件夹中放置一个.htaccess文件(我指的是找到index.php文件的位置)
创建一个.htacces文件并输入以下代码:
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
当它无法修复时,请告诉我。可能是您的分页配置设置不正确。查看@Justin-j give时,它应该会起作用。在这种情况下,我可以使用同一页面的不同url访问吗?
例如:
- localhost/project/index.php/member
- 本地主机/项目/成员
在我的根文件夹中使用.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我已经解决了这个问题
这是一个愚蠢的错误
在标题中,我没有使用
然后,我在application/config/config.php中使用allgo并找到index_页面remove index.php并将其保留为空。索引页面现在是空的。但当我移动到另一个页面(在分页中单击“下一步”)时,它会使我在网站中的视图混乱,因为我没有在$config[base_url]中添加索引。谢谢你的回答,但它对我不起作用“04 page not Found the page your required not Found.”但是,如果我在base_url()中的riview之后添加“index”。“回顾”。。同样的问题,CSS或页面视图混乱。我的问题不在生成分页的问题上,但当我将页面移动到下一个页面,CSS视图混乱时,请回答@Oteng Kwame,但我已经这样做了,它仍然不起作用。我将.htaccess文件放在我的根文件夹中。示例:项目/应用程序/控制器/成员/索引我的根目录在项目文件夹中,我将.htaccess放在项目/中,htaccess我的意思是,我可以在我的页面中使用不同的url获得相同的视图吗?因为如果您尝试使用第一个和第二个url,这将显示页面的不同视图