在PHP中找不到404页面 [英] 404 page not found in PHP
本文介绍了在PHP中找不到404页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我是PHP新手。我正在使用MVC模型来创建我的页面。
我想显示用户列表。我创建了所有三个页面,即模型页面,视图页面和控制器页面。
但是当我在浏览器上运行该页面时,它显示错误页面
404找不到页面。
有人可以帮我吗...
提前付款
我尝试过:
型号页面
userlist_model.php
Hello,
I am new in PHP. I am using a MVC model to create my page.
I want to display users list. I create all three pages i.e. model page, view page and controller page.
But when I run that page on browser it display error page
"404 Page not found".
Can anybody help me please...
Thanx in advance
What I have tried:
Model page
userlist_model.php
<?php
class Userlist_model extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
$this->table_name='users'
}
public function select_record($where=NULL, $select=Null,$jointable=NULL,$joinkey=Null, $per_page=NULL, $limit=Null,$order_by=NULL,$count=false)
{
if($where!=NULL)
$this->db->where($where);
if($select!=NULL)
$this->db->select($select);
if($jointable!=Null)
$this->db->join($jointable,$joinkey);
if($order_by!=Null)
$this->db->order_by($order_by);
if($limit!=Null)
$this->db->limit($limit,$per_page);
$query=$this->db->get($this->table_name);
if($count==true)
{
return $query->num_rows();
}
else
{
return $query->result();
}
}
public function insert_record($insert_data)
{
$this->db->insert($this->table_name,$insert_data);
return $this->db->insert_id();
}
public function edit_record($update_data,$cond)
{
return $this->db->update($this->table_name,$update_data,$cond);
}
public function delete_record($where)
{
$this->db->delete($this->table_name,$where);
}
public function custom_query($query)
{
$query=$this->db->query($query);
return $query->result();
}
public function count_all_record()
{
$this->db->count_all($this->table_name);
}
}
?>
控制器页面
user_list.php
controller page
user_list.php
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
class Userlist extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->library('form_validation');
$this->load->model('admin/userlist_model');
is_logged_in();
get_role_access();
restrict_privillages();
}
public function index($page=1)
{echo "Hello controller";
$suffix='';
$search_per_page='10';
$search_keyword='';
$data['search_keyword']='';
if(!empty($_GET))
{
$suffix-'?'.http_build_query($_GET);
if(!empty($_GET['search_per_page']))
$search_per_page=$this->input->get('search_per_page');
if(!empty($_GET['search_keyword']))
$search_keyword=trim(addslashes($this->inpu>get('search_keyword')));
$data['search_keyword']=$this->input->get('search_keyword');
}
$data['search_per_page']=$search_per_page;
$where_cond='activated=1';
if(!empty($search_keyword)) $where_cond.="AND (email LIKE '%".$search_keyword."%')";
$select_cond="id,email,permissions, activated, activation_code, activated_at, last_login, persist_code, reset_password_code, first_name, last_name, created_at, updated_at";
$order_by_cond="created_at";
$per_page=$search_per_page;
$limit_cond=$per_page;
if($page>1)
{
$page=$page-1;
if($page==0) $page=1;
$page=$per_page*$page;
}
else
$page=0;
$data['page']=$page;
$per_page_cond=$page;
$total_record=$this->userlist_model->select_record($where_cond,$select_cond,'','','','',$order_by_cond,true);
$data['result']=$this->userlist_model->select_record($where_cond,$select_cond,'','',$per_page_cond,$limit_cond,$order_by_cond);
$pagination_base_url=base_url().'/admin/userlist/index';
$pagination_total_row=$total_record;
$pagination_per_page=$per_page;
$pagination_suffix=$suffix;
$pagination_uri_segment=4;
$pagination_page=$page;
$pagination_showing_total_record = count($data['result']);
$data['pagination']=set_pagination_helper($pagination_base_url,$pagination_total_row,$pagination_per_page,$pagination_suffix,$pagination_uri_segment,$pagination_page,$pagination_showing_total_record);
$this->load->view('admin/user_list',$data);
}
}
?>
查看页面
user_list.php
view page
user_list.php
<?php $this->load->view('admin/includes/header');?>
<?php $this->load->view('admin/includes/sidebar');?>
<?php echo "Hello";?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>User</h1>
<ol class="breadcrumb">
<li><a href="<?php echo base_url()?>admin/dashboard">Dashboard</a></li>
<li class="active">User</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-md-12">
<div class="box">
<div class="box-header">
<?php if($this->session->flashdata('success_message')!=null){?>
<div class="col-md-12">
<div class="alert alert-success">
<?php echo $this->session->flashdata('success_message');?>
</div>
</div>
<?php }?>
<?php echo "Helloview";?>
<div class="col-md-12" <?php echo privilege('user_list/add');?>><a href="<?php echo base_url()?>admin/user_list/add" class="btn btn-sm btn-info btn-flat pull-left">Add New</a> </div>
<div class="clearfix"></div><div class="col-md-12"> </div>
<form class="form-horizontal" name="SearchForm" id="SearchForm" action="<?php echo base_url();?>admin/user_list">
<div class="col-md-6">
<div class="form-group">
<div class="col-sm-3">
<select class="form-control input-sm" name="search_per_page" >
<option value="10" <?php echo($search_per_page == 10) ? 'selected=""' : '';?>>10</option>
<option value="25" <?php echo($search_per_page == 25) ? 'selected=""' : '';?>>25</option>
<option value="50" <?php echo($search_per_page == 50) ? 'selected=""' : '';?>>50</option>
<option value="100" <?php echo($search_per_page == 100) ? 'selected=""' : '';?>>100</option>
</select>
</div>
<label class="col-sm-3 control-label">Record per page</label>
</div>
</div>
<div class="col-md-6">
<input type="text" name="search_keyword" id="search_keyword" class="form-control input-sm" placeholder="Search Keyword" value="<?php echo(!empty($search_keyword)) ? $search_keyword : '';?>">
</div>
</form>
</div>
<!-- /.box-header -->
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tbody>
<tr>
<th>#</th>
<th>Email</th>
<th>Register Date</th>
<th>Last Login</th>
<th>Email Status</th>
<th>Status</th>
<th <?php echo (privilege('user_list/edit')!=null && privilege('user_list/delete')!=null) ? 'style="display:none"':'';?>>Action</th>
</tr>
<?php if(!empty($result)){
$i=($page==0) ? 1 : $page + 1;
foreach($result as $row):
?>
<tr>
<td><?php echo $i;?></td>
<td><?php echo $row->st_email;?></td>
<td><?php echo($row->dt_added_date!='0000-00-00 00:00:00') ? date('d-m-Y',strtotime($row->dt_added_date)) : '-';?></td>
<td><?php echo($row->dt_last_login!='0000-00-00 00:00:00') ? date('d-m-Y',strtotime($row->dt_last_login)) : '-';?></td>
<td><?php echo($row->in_email_status==1) ? 'Activated' : 'Pending';?></td>
<td><?php echo($row->flg_is_active==1) ? 'Active' : 'Inactive';?></td>
<td <?php echo(privilege('user_list/edit')!=null && privilege('user_list/delete')!=null) ? 'style="display:none"':'';?>>
<a class="edti_del" href="<?php echo base_url()?>admin/user_list/edit/<?php echo md5($row->in_user_id)?>">></a>
<a class="edti_del" href="<?php echo base_url()?>admin/user_list/delete/<?php echo md5($row->in_user_id)?>" onclick="return confirm('Are you sure you want to delete this user?');" <?php echo privilege('user_list/delete');?>></a>
</td>
</tr>
<?php $i++; endforeach; } else {?>
<tr><td colspan="100%" class="text-center">Record Not Found!</td></tr>
<?php }?>
<?php if(!empty($result) && !empty($pagination)) {?>
<tr>
<td colspan="12">
<?php echo $pagination;?>
</td>
</tr>
<?php }?>
</tbody>
</table>
</div>
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.row -->
<!-- Main row -->
<!-- /.row (main row) -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php $this->load->view('admin/includes/footer');?>
<script>
$('#search_keyword').keypress(function(e) {
if(e.which == 13) {
$('#SearchForm').submit();
}
});
</script>
推荐答案
this-> load-> database();
this->load->database();
this-> table_name ='users'
}
public function select_record(
this->table_name='users' } public function select_record(
where = NULL,
where=NULL,
这篇关于在PHP中找不到404页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文