2013-12-04 2 views
0

В приведенном ниже кодеинигере я разместил контроллер и модель. В моей таблице членства у меня есть 4 названия экзамена, месяц, год и название колледжа.Обновление итоговой записи в таблице отображает другую запись в таблице

Exam name month year college name 
anna univ feb 2013 kings 
anna  sep 2014 srm 

Теперь моя цель, когда я войти в системе с царями колледжем он показать эту конкретную информацию колледжа. Когда я обновить Короли информацию, которую он отображает SRM информации also.Pls помочь мне решить эту проблему. Контроллер:

class Exam_site extends ci_controller 
{ 
    function index() 
      { 
        $data = array(); 
        $college_name = $this->session->userdata('college_name'); 
        if($query = $this->exam_model->get_records($college_name)) 
       { 
         $data['records'] = $query; 
       } 

      $this->load->view('exam_view', $data); 


      } 

      function index1() 
    { 
     $data   = array(); 
     $keyword   = $this->input->post('keyword'); 
     if($keyword!=""){ 
      $data['results'] = $this->exam_model->search($keyword); 
     } 
     $this->load->view('exam_view', $data); 

    } 

    function input() 
     { 
      $data = array(); 

      $this->load->view('exam_view', $data); 
     } 





    function manage_customers() 
    { 
       $data['title']="Manage Customers"; 
       //query model to get data results for form 
       $data=array(); 

      if($query=$this->exam_model->get_customer_records()) 

      { 
       $data['records']=$query; 
      }//end of if bracket 

      $editcustomer = $this->input->post('editcustomer'); 

      if($this->input->post('editcustomer') != false) 

      { 

      foreach($editcustomer as $row_id) 
       { 
        $this->form_validation->set_rules("exam_name_" .$row_id,"'exam name'","required");//to show validation in udata screen 
        $this->form_validation->set_rules("month_".$row_id,"`month`","required");//to show validation in udata screen 
        $this->form_validation->set_rules("year_".$row_id,"`year`","required");//to show validation in udata screen 

       }//end of foreach bracket 
      }//end of if bracket 

      if ($this->form_validation->run() == FALSE) 

       { 

        $data["message"]=""; 
        $this->load->view("exam_view",$data); 
       } //end of if bracket 

       else 

        { 

       // single update - working 
       if($this->input->post('editcustomer') != false) 
       { 
        foreach ($editcustomer as $row_id) 
        { 
         $data = array( 
         'college_name' => $this->session->userdata('college_name'), 
         'exam_name' => $this->input->post('exam_name_'.$row_id), 
         'month' => $this->input->post('month_'.$row_id), 
         'year' => $this->input->post('year_'.$row_id), 
         );//end of the array 
       //this is update the data when it click 
       $this->exam_model->update_customer_records($row_id, $data); 

        }//end of foreach bracket 
       //Not Working 
        $this->session->set_flashdata('dbaction', 'Selected Records have been updated successfully'); 
        redirect('exam_site/manage_customers', 'refresh'); 
        }//end of if bracket 

      }//end of function 
    } 

}//end of class 

модель:

class Exam_model extends ci_model { 



    function get_records($college_name) 
    { 
     $this->db->where('college_name',$college_name); 
     $query = $this->db->get('exam_table'); 
     return $query->result(); 

    } 

/* function add_record($data) 
    { 
     $this->db->insert('exam_table', $data); 
     return; 
    }*/ 

    function update_record($data) 
    { 
     $temp = 'exam_name'.$this->uri->segment(3); 
     echo "temp:".$temp; 
     echo "data:".$this->input->post($temp); 
     $data1 = array(

      'exam_name' => $this->input->post('exam_name.$this->uri->segment(3)'), 
      'month'=>$this->input->post('month.$this->uri->segment(3)'), 
      'year'=>$this->input->post('year.$this->uri->segment(3)') 

      ); 
       echo "exam_name:".$data1['exam_name']; 
     echo " month:".$data1['month']; 
     echo "year:".$datal['year']; 


       } 


    function send($data) { 
     $this->db->insert('msg', $data); 
     return; 
    } 

    function get_customer_records() 
    { 
     $query = $this->db->get('exam_table'); 
     return $query->result(); 

    } 


    function update_customer_records($row_id, $data) 
    { 

     $this->db->where('id',$row_id); 
     $this->db->update('exam_table',$data); 
     if ($this->db->_error_number() == 1451) 
       { 
       $this->session->set_flashdata('updatecascade', 'updatecascade'); 
       } 
       if ($this->db->_error_number() == "") 
       { 
       $this->session->set_flashdata('update', 'update'); 
       } 
    } 



} 
+0

Что такое информация «srm»? – Dev

+0

srm информация экзамен имя месяц год – user2991258

+0

Вы можете взять тестовый код? Трудно понять, что вы на самом деле пытаетесь сделать. – Charlie

ответ

0

Можете ли вы предоставить значение $ this-> вход-> после ('editcustomer')?
Также в вашем контроллере отсутствует один закрывающий кронштейн} в конце. Строка комментария, которая говорит, что // конец функции на самом деле является конечной скобкой else.

Смежные вопросы