'sexual'=> $ this-> input-> post('slogender'), 'address'=> $ this-> input-> post('txtaddress') ); $ this-> db-> where('user_id',$ id); $ this-> db-> update('tbluser',$ arr); if($ this-> db-> affected_rows()> 0){ redirect(base_url()。'user / user'); } } } ?> user_view.php <!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1 /DTD/xhtml1-transitional.dtd\"> < meta http-equiv =Content-Typecontent = text / html; charset = utf-8/> < title>用户 Add new <?php / * GT?; <?php print_r($ user); ?><?php * /?> <?php $ n = 1; foreach($ user as as $ row): $性别=($ row->性别== 1)?'男':'女'; ?> <?php $ n ++; endforeach; ?> 否 用户名 性别 地址 行动 <?= $ n?> <?= $ row-> username; ?> <?= $ gender; ?> <?= $ row->地址; ?> 编辑 删除 user_view_add.php <?= form_open('user / user / submit'); ?> 用户名 <?= form_input('txtusername'); ?> 性别 <?= form_dropdown('slogender',数组('1'=>'男','2' => '女')); ?> 地址 <?= form_textarea('txtaddress'); ?> <?= form_submit('btnsubmit','保存'); ?> <?= form_close(); ?> user_view_edit.php <?= form_open('user / user / update'); ?> 用户名 <?= form_input('txtusername',$ get_edit-> username); ?> <?= form_hidden('txtid',$ get_edit-> user_id); ?> 性别 <?= form_dropdown('slogender',array('1'=> ;'男','2'=>'女'),$ get_edit->性别); ?> 地址 <?= form_textarea('txtaddress',$ get_edit->地址); ?> <?= form_submit('btnsubmit','保存'); ?> <?= form_close(); ?> 错误:编辑和添加都找不到对象 路径:模型/用户/user_model.php view / user / user_view.php /user_view_add.php /user_view_edit.php 我尝试过: 错误:找不到对象编辑和添加 路径:model / user / user_model.php view / user / user_view.php /user_view_add.php / user_view_edit.php user.php<?phpdefined('BASEPATH') OR exit('No direct script access allowed');class User extends CI_Controller {function __construct() {parent::__construct();$this->load->model('user/user_model','m');}function index() {$data['user'] = $this->m->get_user();$this->load->view('user/user_view', $data);}function add() {$this->load->view('user/user_view_add');}function submit() {$this->m->submit();}function edit($id) {$data['get_edit'] = $this->m->get_edit($id);//print_r($data);$this->load->view('user/user_view_edit', $data);}function update() {$this->m->update();}}user_model.php<?phpdefined('BASEPATH') OR exit('No direct script access allowed');class User_model extends CI_Model {function get_user() {$query = $this->db->get('tbluser');return $query->result();}function submit() {$arr = array('username'=>$this->input->post('txtusername'),'gender'=>$this->input->post('slogender'),'address'=>$this->input->post('txtaddress'));//print_r($arr); exit();$this->db->insert('tbluser', $arr);if($this->db->affected_rows()>0) {redirect(base_url().'user/user/');}}function get_edit($id) {$query = $this->db->get_where('tbluser', array('user_id'=>$id));return $query->row();}function update() {$id = $this->input->post('txtid');//echo $id; exit();$arr = array('username'=>$this->input->post('txtusername'),'gender'=>$this->input->post('slogender'),'address'=>$this->input->post('txtaddress'));$this->db->where('user_id', $id);$this->db->update('tbluser', $arr);if($this->db->affected_rows() > 0) {redirect(base_url().'user/user');}}}?>user_view.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>userAdd New <?php /*?> <?php print_r($user); ?><?php */?> <?php $n=1;foreach($user as $row):$gender = ($row->gender == 1)?'Male':'Female'; ?> <?php $n++; endforeach; ?> No Username Gender Address Action <?= $n ?> <?= $row->username; ?> <?= $gender; ?> <?= $row->address; ?> Edit Delete user_view_add.php<?= form_open('user/user/submit'); ?> Username <?= form_input('txtusername'); ?> gender <?= form_dropdown('slogender', array('1'=>'Male', '2'=>'Female')); ?> Address <?= form_textarea('txtaddress'); ?> <?= form_submit('btnsubmit', 'Save'); ?> <?= form_close(); ?>user_view_edit.php<?= form_open('user/user/update'); ?> Username <?= form_input('txtusername', $get_edit->username); ?> <?= form_hidden('txtid', $get_edit->user_id); ?> gender <?= form_dropdown('slogender', array('1'=>'Male', '2'=>'Female'), $get_edit->gender); ?> Address <?= form_textarea('txtaddress', $get_edit->address); ?> <?= form_submit('btnsubmit', 'Save'); ?> <?= form_close(); ?>error: object not found for both edit and addpath : model/user/user_model.php view/user/user_view.php /user_view_add.php /user_view_edit.phpWhat I have tried:error: object not found for both edit and addpath : model/user/user_model.php view/user/user_view.php /user_view_add.php /user_view_edit.php推荐答案 this-> load-> model('user / user_model','m'); } 函数索引(){ this->load->model('user/user_model','m');}function index() { data ['user'] = data['user'] = this-> m-> get_user(); this->m->get_user(); 这篇关于添加和编辑不工作它的唯一显示页面错误plz帮助修复这个PHP codignitor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 11-03 07:24