2016-09-02 7 views
0

Databaseエラー発生しました
エラー番号:1054
不明な列 'UN' 'フィールドリスト' で
UPDATE student SET un = NULL、pw = NULL、n = id
ファイル名NULL IS NULL:D:\インストール\ WAMP \ WWW \のCI \システム\データベース\ DB_driver.php
行番号:331は、エラー番号を発生しました:1054

私は助けが必要です。私の完全なコードは次のとおりです。

editcon.php: -

//Controller 
<?php 
    class editcon extends CI_Controller 
    { 
    function edit() 
    { 
    $id = $this->input->get('id'); 
    $this->load->model('editmodel'); 
    $dis['info']=$this->editmodel->getuserid($id); 
    $this->load->view('editview',$dis); 
    } 

    function update() 
    { 
    $id = $this->input->post['uid']; 
    $username = $this->input->post['un']; 
    $password = $this->input->post['pw']; 
    $stdname = $this->input->post['n']; 
    $data = array('un'=>$username,'pw'=>$password,'n'=>$stdname); 
     $this->load->model('editmodel'); 
     if($this->editmodel->updatebyid($data,$id)) 
     { 
      $list['info'] = $this->listmodel->std_list(); 
     $this->load->view('listview',$list); 
     }else 
     { 
     echo "error"; 
     } 
    } 
    } 
?> 

//editmodel:-          //model 
<?php 
    class editmodel extends CI_Model 
    { 
     function getuserid($id) 
     { 
     $this->load->database(); 
     $this->db->where('id',$id); 
     $query = $this->db->get('student'); 
     return $query->result(); 
     } 

     function updatebyid($data,$id) 
     { 
     $this->load->database(); 
     $this->db->where('id',$id) 
       ->update('student',$data); 
     return true; 
     } 
    } 
?> 

//editview:-     //view 
<html> 
    <head><title>Student Edit</title></head> 
    <body> 
    <?php 
     if(isset($data)) 
     { 
     ?> 
     <h1>Update Form</h1> 
       <?php echo form_open('editcon/update'); ?> 
       <table> 
      <tr> 
      <td>User name</td> 
      <input type="hidden" name="uid" value="<? echo $info[0]->id?>"> 
      <td><input type="text" name="un" 
       value="<?php 
       foreach($info as $row) 
       { 
       echo $row->uname; 
       } 
       ?>"> 
       </td> 
      </tr> 

      <tr> 
      <td>Password</td> 
      <td><input type="text" name="pw" value="<?php echo $info[0]->pword; ?>"</td> 
      </tr> 

      <tr> 
      <td>Name</td> 
      <td><input type="text" name="n" value="<?php echo $info[0]->sname; ?>"</td> 
      </tr> 

      <tr> 
      <td><input type="submit" value="update" name="s1"></td> 
      </tr> 
      </table> 
     </form> 
    <?php 
     }else 
     { 
     ?> 
     } 
    </body> 
</html> 

//listview:        //view  //in here pass id on edit link 
<html> 
<head><title>Listview</title></head> 
<body> 
<center> 
     <table border="2"> 
      <tr> 
      <td>Username</td> 
      <td>Password</td> 
      <td>Name</td> 
      </tr> 
      <?php foreach($info as $row) 
       { 
      ?> 
      <tr> 
      <?php $id=$row->id; ?> 
      <td><?php echo $row->uname; ?></td> 
      <td><?php echo $row->pword; ?></td> 
      <td><?php echo $row->sname; ?></td> 
      <td><a href="http://localhost/ci/editcon/edit/?id=<?php echo $id; ?>">edit</a></td> 
      </tr> 
     <?php } ?> 
     </table> 
    </center> 
</body> 
</html> 
+0

db構造とは何ですか? –

+0

あなたの質問をよりよく編集する – user4419336

答えて

0

すでに "学生" データベースhaventは「国連の列に、あなたを言っているエラー。

また、ポスト変数メソッドを変更します。 これに$this->input->post("form_input_name")を入力してください。

$id = $this->input->post('uid'); 
$username = $this->input->post('un'); 
$password = $this->input->post('pw'); 
$stdname = $this->input->post('n'); 
関連する問題