我是新手,正在使用codeigniter。问题出在我的更新页面上,我可以更新用户,但它的UI有问题,因为它没有正确显示,但数据在那里。除这一页外,所有页面都可以。我想这与我的链接或功能有关。请帮忙。
这是我的编辑链接。http://localhost/project/users/edit/1
,它进入我的更新页面,加载所有数据,但不加载资产/ui。真的很难解决这个问题。
这是我的控制器
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Users extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('user_model');
}
function index()
{
$data['record'] = $this->user_model->getusers();
$this->load->view('user_page', $data);
}
public function edit()
{
$data['record']=$this->user_model->getid();
$this->load->view('user_update',$data);
}
public function update()
{
$data = array(
'firstname' => $this->input->post('firstname'),
'lastname' => $this->input->post('lastname'),
'username' => $this->input->post('username'),
'password' => $this->input->post('password'),
);
$this->user_model->update($data);
redirect('users');
}
}
这是我的型号
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User_Model extends CI_Model
{
function getusers()
{
$query = $this->db->get('users');
return $query->result();
}
function getid()
{
$this->db->where('id', $this->uri->segment(3));
$query = $this->db->get('users');
return $query->result();
}
function update($data)
{
$this->db->where('id', $this->input->post('id'));
$this->db->update('users',$data);
}
}?>
我所有的风格都是这样的。
<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
对于js
<script src="assets/js/bootstrap.min.js"></script>
您需要确保您确实已经在图像、样式表和javascript的所有链接中指定了此代码。<?php base_url();?>assets
仔细检查一下,让我们知道它是否有效。
看起来您已经更新了.htaccess文件,从基于编辑链接的路径中删除了"index.php"页面:http://localhost/project/users/edit/1
如果您使用CodeIgniter文档提供的.htaccess规则,请将"assets"添加到RewriteCond
中,这样到您的资产的链接就不会通过index.php:重新路由
RewriteEngine on
RewriteCond $1 !^(index'.php|images|assets|robots'.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]