您好我已经在我的网页中点击了分页链接获取错误
未找到404页面
找不到您请求的页面。
控制器:
class Blogs extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->library('form_validation');
$this->load->library("pagination");
$this->load->model('blogs_model');
if($this->session->userdata('admin_logged_in')){
$this->data['admin_details'] = $this->session->userdata('admin_logged_in');
}
else{
redirect('welcome');
}
}
function index()
{
$config = array();
$config["base_url"] = base_url() . "blogs/index";
$config["total_rows"] = $this->blogs_model->record_count();
$config["per_page"] = 11;
$config["uri_segment"] = 4;
$this->pagination->initialize($config);
$page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
$data['records'] = $this->blogs_model->get_blogs($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();
$data['mainpage']='blogs';
$data['mode']='all';
$this->load->view('templates/template',$data);
}
}
型号:
function get_blogs($limit, $start)
{
$this->db->limit($limit, $start);
$this->db->Select('blogs.*');
$this->db->From('blogs');
$this->db->where(array('blogs.status'=>1));
$this->db->order_by("date", "desc");
$q=$this->db->get();
if($q->num_rows()>0)
{
return $q->result();
}
else
{
return false;
}
}
查看:
<div id="main">
<div class="full_w">
<div class="h_title">
<div class="lefttitle fl">
Blogs
</div>
<div class="rightbutton fr">
<a class="button add" href="<?php echo site_url();?>/blogs/add">Add </a>
<a class="button add" href="<?php echo site_url();?>/category">Category </a>
<a class="button del" href="<?php echo site_url();?>/blogs/deactivated">Deactivated Blogs</a>
</div>
</div>
<table>
<thead>
<tr>
<th scope="col">Featured Blogs</th>
<th scope="col">S.No</th>
<th scope="col">Blog Title</th>
<th scope="col">Author</th>
<th scope="col">Comments</th>
<th scope="col">Date</th>
<th scope="col">Hits</th>
<th scope="col" style="width: 65px;">Modify</th>
</tr>
</thead>
<tbody>
<?php if(isset($records) && is_array($records) && count($records)>0): ?>
<?php $i=0;foreach($records as $r):$i++;?>
<tr>
<td><input type="checkbox" name="checkbox" value="<?php echo $r->blog_id;?>"></td>
<td class="align-center"><?php echo $i;?></td>
<td><?php echo $r->blog_title;?></td>
<td><?php echo $r->username;?></td>
<td><span data-plugin="comment-count"><?php echo $comments;?></span></td>
<td><?php echo $r->date;?></td>
<td><?php echo $r->ne_views;?></td>
<td>
<a href="<?php echo site_url();?>/blogs/edit/<?php echo $r ->blog_id ;?>" class="table-icon edit" title="Edit"></a>
<a href="<?php echo site_url();?>/blogs/delete/<?php echo $r ->blog_id ;?>" onclick="return confirm('Are you sure to delete');" class="table-icon delete" title="Delete"></a>
</td>
</tr>
<?php endforeach ;endif;?>
</tbody>
</table>
<p><?php echo $links; ?></p>
<button id="someButton">Activate</button>
</button>
</div>
</div>
<div class="clear"></div>
是否需要进行任何更改,不知道为什么显示为404页面未找到。
它将网址显示为:staging.website.com/admin/index.php/blogs
这是截至目前显示的网址。
答案 0 :(得分:1)
通过添加此格式的代码解决
$config = array();
$config["base_url"] = base_url("index.php/blogs/index");
答案 1 :(得分:0)
更改以下代码
$config["base_url"] = base_url("blogs/index");
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
以及
$config["uri_segment"] = 3;