2016-05-10 11 views
0

私はCodi​​gniterに取り組んでいます、私は、フォームのデータを掲載して問題を持っている..私の形で 、異なる部分があり、私はその異なるセクションのフォームのデータは、(CodeIgniterの)を投稿することができません

を配列に入れていますここに私のコード(コントローラ)がある。ここ

 <?php 
     class Resume extends CI_Controller{ 
     var $user_id; 
     function __construct(){ 
     parent::__construct(); 
     $this->user_id = $this->session->userdata('user_id'); 
     $this->load->model("Resume_model"); 
     if($this->session->userdata('user_id') == NULL){ 
      redirect('user/login','refresh'); 
     } 
    } 
    public function index(){ 
     $this->Resume(); 
    } 
    public function Resume(){ 

     if($this->input->post('Skills')){ 
      $Resume = $this->input->post(); 
      $ResumeInsert=array(); 
      $ResumeUpdate=array(); 
      $Key_Resume__ExistIDs=array(); 

       foreach($this->input->post('Person_id') as $key =>$value){ 
        $ResumeInsert[$key]['updated'] = Date("Y-m-d"); 
        $ResumeInsert[$key]['Importance_JK'] = $Resume['Importance_JK']; 
        $ResumeInsert[$key]['user_FK'] = $user_id; 
        $ResumeInsert[$key]['Person_id'] = $Resume['Person_id'][$key]; 
        $ResumeInsert[$key]['email_contact'] = $Resume['email_contact'][$key]; 
        $ResumeInsert[$key]['Contact_Phone'] = $Resume['Contact_Phone'][$key]; 
        $ResumeInsert[$key]['communication'] = $Resume['communication'][$key]; 
        $ResumeInsert[$key]['creativity'] = $Resume['creativity'][$key]; 
        $ResumeInsert[$key]['team_work'] = $Resume['team_work'][$key]; 
        $ResumeInsert[$key]['organizational'] = $Resume['organizational'][$key]; 
        $ResumeInsert[$key]['Leadership'] = $Resume['Leadership'][$key]; 
        $ResumeInsert[$key]['Productivity'] = $Resume['Productivity'][$key]; 
        $ResumeInsert[$key]['Postal_Address'] = $Resume['Postal_Address'][$key]; 
        $ResumeInsert[$key]['Career_objective'] = $Resume['Career_objective'][$key]; 

       } 

      foreach($this->input->post('emp_id') as $key =>$value){ 
        $ResumeInsert[$key]['resume_keyid'] = $Resume['emp_id'][$key]; 
        $ResumeInsert[$key]['employer_name'] = $Resume['employer_name'][$key]; 
        $ResumeInsert[$key]['start_Date'] = $Resume['start_Date'][$key]; 
        $ResumeInsert[$key]['end_date'] = $Resume['end_date'][$key]; 
        $ResumeInsert[$key]['type_id'] = $Resume['type_id'][$key]; 
        $ResumeInsert[$key]['position'] = $Resume['position'][$key]; 
        $ResumeInsert[$key]['responsibility'] = $Resume['responsibility'][$key]; 
        $ResumeInsert[$key]['Skills'] = $Resume['Skills'][$key]; 
        print_r ($ResumeInsert);exit; 
      } 

      foreach($this->input->post('resume_id1') as $key =>$value){ 
        $ResumeInsert[$key]['edu_id'] = $Resume['resume_id1'][$key]; 
        $ResumeInsert[$key]['year_gain'] = $Resume['year_gain'][$key]; 
        $ResumeInsert[$key]['qualification_name'] = $Resume['qualification_name'][$key]; 
        $ResumeInsert[$key]['institution_name'] = $Resume['institution_name'][$key]; 
        $ResumeInsert[$key]['outstanding_Ach'] = $Resume['outstanding_Ach'][$key]; 
        $ResumeInsert[$key]['aquired_skill'] = $Resume['aquired_skill'][$key]; 
        $ResumeInsert[$key]['expiry'] = $Resume['expiry'][$key]; 
        $ResumeInsert[$key]['Application_of_Skill'] = $Resume['Application_of_Skill'][$key]; 

       } 
      foreach($this->input->post('resume_id2') as $key =>$value){ 
        $ResumeInsert[$key]['resume_skillID'] = $Resume['resume_id2'][$key]; 
        $ResumeInsert[$key]['skill_name'] = $Resume['skill_name'][$key]; 
        $ResumeInsert[$key]['Licences_permits'] = $Resume['Licences_permits'][$key]; 
        $ResumeInsert[$key]['date_Achived'] = $Resume['date_Achived'][$key]; 
        $ResumeInsert[$key]['expiry_renewal'] = $Resume['expiry'][$key]; 
        $ResumeInsert[$key]['skill_work'] = $Resume['application_of_skill'][$key]; 
        $ResumeInsert[$key]['course_tilte'] = $Resume['course_tilte'][$key]; 

       } 

      foreach($this->input->post('resume_id3') as $key =>$value){ 

        $ResumeInsert[$key]['hobbyId'] = $Resume['resume_id3'][$key]; 
        $ResumeInsert[$key]['hobby_name'] = $Resume['hobby_name'][$key]; 
        $ResumeInsert[$key]['achievement_name'] = $Resume['achievement_name'][$key]; 
        $ResumeInsert[$key]['Application_OF_hobby_work'] = $Resume['Application_of_Skill'][$key]; 

       } 

       foreach($this->input->post('resume_id4') as $key =>$value){ 

        $ResumeInsert[$key]['ref_resume_ID'] = $Resume['resume_id4'][$key]; 
        $ResumeInsert[$key]['referee_name'] = $Resume['referee_name'][$key]; 
        $ResumeInsert[$key]['Position_referee'] = $Resume['Position'][$key]; 
        $ResumeInsert[$key]['company_name_ref'] = $Resume['company_name'][$key]; 
        $ResumeInsert[$key]['phone_ref'] = $Resume['phone_ref'][$key]; 
        $ResumeInsert[$key]['contact_email_ref'] = $Resume['contact_email'][$key]; 
        $ResumeInsert[$key]['reference_Type'] = $Resume['reference_Type'][$key]; 
        $ResumeInsert[$key]['Application_of_Skill_ref'] = $Resume['Application_of_Skill'][$key]; 

       } 

       foreach($this->input->post('resume_id5') as $key =>$value){ 

        $ResumeInsert[$key]['Application_Id'] = $Resume['resume_id5'][$key]; 
        $ResumeInsert[$key]['app_date_sent'] = $Resume['date_sent'][$key]; 
        $ResumeInsert[$key]['app_busisness_name'] = $Resume['app_busisness_name'][$key]; 
        $ResumeInsert[$key]['app_address'] = $Resume['app_address'][$key]; 
        $ResumeInsert[$key]['app_contact_phone'] = $Resume['app_contact_phone'][$key]; 
        $ResumeInsert[$key]['app_outcome'] = $Resume['app_outcome'][$key]; 
        $ResumeInsert[$key]['app_date_closed'] = $Resume['app_date_closed'][$key]; 

       } 
         if(isset($Resume['id'][$key])) 
         { 
         // echo "test";exit; 
         $Key_Resume__ExistIDs[]=$Resume['id'][$key]; 
         if($ResumeInsert[$key]['Person_id'] != ""){ 
          $ResumeUpdate[$key]['Person_id'] = $ResumeInsert[$key]['Person_id']; 
         } 
          if($ResumeInsert[$key]['email_contact'] != ""){ 
          $ResumeUpdate[$key]['email_contact'] = $ResumeInsert[$key]['email_contact']; 
         } 
          if($ResumeInsert[$key]['Contact_Phone'] != ""){ 
          $ResumeUpdate[$key]['Contact_Phone'] = $ResumeInsert[$key]['Contact_Phone']; 
         } 
          if($ResumeInsert[$key]['communication'] != ""){ 
          $ResumeUpdate[$key]['communication'] = $ResumeInsert[$key]['communication']; 
         } 
          if($ResumeInsert[$key]['creativity'] != ""){ 
          $ResumeUpdate[$key]['creativity'] = $ResumeInsert[$key]['creativity']; 
         } 
          if($ResumeInsert[$key]['team_work'] != ""){ 
          $ResumeUpdate[$key]['team_work'] = $ResumeInsert[$key]['team_work']; 
         } 
          if($ResumeInsert[$key]['organizational'] != ""){ 
          $ResumeUpdate[$key]['organizational'] = $ResumeInsert[$key]['organizational']; 
         } 
          if($ResumeInsert[$key]['Leadership'] != ""){ 
          $ResumeUpdate[$key]['Leadership'] = $ResumeInsert[$key]['Leadership']; 
         } 
          if($ResumeInsert[$key]['Productivity'] != ""){ 
          $ResumeUpdate[$key]['Productivity'] = $ResumeInsert[$key]['Productivity']; 
         } 
          if($ResumeInsert[$key]['Postal_Address'] != ""){ 
          $ResumeUpdate[$key]['Postal_Address'] = $ResumeInsert[$key]['Postal_Address']; 
         } 

          if($ResumeInsert[$key]['Career_objective'] != ""){ 
          $ResumeUpdate[$key]['Career_objective'] = $ResumeInsert[$key]['Career_objective']; 
         } 


         if($ResumeInsert[$key]['resume_keyid'] != ""){ 
          $ResumeUpdate[$key]['resume_keyid'] = $ResumeInsert[$key]['resume_keyid']; 
         } 
         if($ResumeInsert[$key]['employer_name'] != ""){ 
          $ResumeUpdate[$key]['employer_name'] = $ResumeInsert[$key]['employer_name']; 
         } 
         if($ResumeInsert[$key]['start_Date'] != ""){ 
          $ResumeUpdate[$key]['start_Date'] = $ResumeInsert[$key]['start_Date']; 
         } 
         if($ResumeInsert[$key]['end_date'] != "") { 
          $ResumeUpdate[$key]['end_date'] = $ResumeInsert[$key]['end_date']; 
         } 
         if($ResumeInsert[$key]['type_id'] != ""){ 
          $ResumeUpdate[$key]['type_id'] = $ResumeInsert[$key]['type_id']; 
         } 
         if($ResumeInsert[$key]['position'] != ""){ 
          $ResumeUpdate[$key]['position'] = $ResumeInsert[$key]['position']; 
        } 

         if($ResumeInsert[$key]['edu_id'] != ""){ 
          $ResumeUpdate[$key]['edu_id'] = $ResumeInsert[$key]['edu_id']; 
         } 
         if($ResumeInsert[$key]['year_gain'] != ""){ 
          $ResumeUpdate[$key]['year_gain'] = $ResumeInsert[$key]['year_gain']; 
         } 
         if($ResumeInsert[$key]['qualification_name'] != ""){ 
          $ResumeUpdate[$key]['qualification_name'] = $ResumeInsert[$key]['qualification_name']; 
         } 
         if($ResumeInsert[$key]['institution_name'] != ""){ 
          $ResumeUpdate[$key]['institution_name'] = $ResumeInsert[$key]['institution_name']; 
         } 
         if($ResumeInsert[$key]['outstanding_Ach'] != ""){ 
          $ResumeUpdate[$key]['outstanding_Ach']= $ResumeInsert[$key]['outstanding_Ach']; 
         } 
         if($ResumeInsert[$key]['aquired_skill'] != ""){ 
          $ResumeUpdate[$key]['aquired_skill'] = $ResumeInsert[$key]['aquired_skill']; 
         } 
         if($ResumeInsert[$key]['expiry'] != ""){ 
          $ResumeUpdate[$key]['expiry'] = $ResumeInsert[$key]['expiry']; 
         } 
         if($ResumeInsert[$key]['Application_of_Skill'] != ""){ 
          $ResumeUpdate[$key]['Application_of_Skill'] = $ResumeInsert[$key]['Application_of_Skill']; 
         } 
         if($ResumeInsert[$key]['resume_skillID'] != ""){ 
          $ResumeUpdate[$key]['resume_skillID'] = $ResumeInsert[$key]['resume_skillID']; 
         } 
         if($ResumeInsert[$key]['skill_name'] != ""){ 
          $ResumeUpdate[$key]['skill_name'] = $ResumeInsert[$key]['skill_name']; 
         } 
         if($ResumeInsert[$key]['Licences_permits'] != ""){ 
          $ResumeUpdate[$key]['Licences_permits'] = $ResumeInsert[$key]['Licences_permits']; 
         } 
         if($ResumeInsert[$key]['date_Achived'] != ""){ 
          $ResumeUpdate[$key]['date_Achived'] = $ResumeInsert[$key]['date_Achived']; 
         } 
         if($ResumeInsert[$key]['expiry_renewal'] !="") { 
          $ResumeUpdate[$key]['expiry_renewal'] = $ResumeInsert[$key]['expiry_renewal']; 
         } 
         if($ResumeInsert[$key]['skill_work'] != ""){ 
          $ResumeUpdate[$key]['skill_work'] = $ResumeInsert[$key]['skill_work']; 
         } 
         if($ResumeInsert[$key]['course_tilte'] != ""){ 
          $ResumeUpdate[$key]['course_tilte'] = $ResumeInsert[$key]['course_tilte']; 
         } 
         if($ResumeInsert[$key]['hobbyId'] != ""){ 
          $ResumeUpdate[$key]['hobbyId'] = $ResumeInsert[$key]['hobbyId']; 
         } 
         if($ResumeInsert[$key]['hobby_name'] != ""){ 
          $ResumeUpdate[$key]['hobby_name'] = $ResumeInsert[$key]['hobby_name']; 
         } 
         if($ResumeInsert[$key]['achievement_name'] != ""){ 
          $ResumeUpdate[$key]['achievement_name'] = $ResumeInsert[$key]['achievement_name']; 
         } 
         if($ResumeInsert[$key]['Application_OF_hobby_work'] != ""){ 
          $ResumeUpdate[$key]['Application_OF_hobby_work'] = $ResumeInsert[$key]['Application_OF_hobby_work']; 
         } 
         if($ResumeInsert[$key]['ref_resume_ID'] != ""){ 
          $ResumeUpdate[$key]['ref_resume_ID'] = $ResumeInsert[$key]['ref_resume_ID']; 
         } 
         if($ResumeInsert[$key]['referee_name'] != ""){ 
          $ResumeUpdate[$key]['referee_name'] = $ResumeInsert[$key]['referee_name']; 
         } 
         if($ResumeInsert[$key]['Position_referee'] != ""){ 
          $ResumeUpdate[$key]['Position_referee'] = $ResumeInsert[$key]['Position_referee']; 
         } 
         if($ResumeInsert[$key]['company_name_ref'] != ""){ 
          $ResumeUpdate[$key]['company_name_ref'] = $ResumeInsert[$key]['company_name_ref']; 
         } 
         if($ResumeInsert[$key]['phone_ref'] != ""){ 
          $ResumeUpdate[$key]['phone_ref'] = $ResumeInsert[$key]['phone_ref']; 
         } 
         if($ResumeInsert[$key]['contact_email_ref'] != ""){ 
          $ResumeUpdate[$key]['contact_email_ref'] = $ResumeInsert[$key]['contact_email_ref']; 
         } 
         if($ResumeInsert[$key]['reference_Type'] != ""){ 
          $ResumeUpdate[$key]['reference_Type'] = $ResumeInsert[$key]['reference_Type']; 
         } 
         if($ResumeInsert[$key]['Application_of_Skill_ref'] != ""){ 
          $ResumeUpdate[$key]['Application_of_Skill_ref'] = $ResumeInsert[$key]['Application_of_Skill_ref']; 
         } 
         if($ResumeInsert[$key]['app_date_sent'] != ""){ 
          $ResumeUpdate[$key]['app_date_sent'] = $ResumeInsert[$key]['app_date_sent']; 
         } 
         if($ResumeInsert[$key]['Application_Id'] != ""){ 
          $ResumeUpdate[$key]['Application_Id'] = $ResumeInsert[$key]['Application_Id']; 
         } 
         if($ResumeInsert[$key]['app_busisness_name'] != ""){ 
          $ResumeUpdate[$key]['app_busisness_name'] = $ResumeInsert[$key]['app_busisness_name']; 
         } 
         if($ResumeInsert[$key]['app_address'] != ""){ 
          $ResumeUpdate[$key]['app_address'] = $ResumeInsert[$key]['app_address']; 
         } 
         if($ResumeInsert[$key]['app_contact_phone'] != "") 
          { 
          $ResumeUpdate[$key]['app_contact_phone'] = $ResumeInsert[$key]['app_contact_phone']; 
          } 
         if($ResumeInsert[$key]['app_outcome'] != ""){ 
          $ResumeUpdate[$key]['app_outcome'] = $ResumeInsert[$key]['app_outcome']; 
         } 
         if($ResumeInsert[$key]['app_date_closed'] != ""){ 
          $ResumeUpdate[$key]['app_date_closed'] = $ResumeInsert[$key]['app_date_closed']; 
         } 
         if($ResumeInsert[$key]['resume_id'] != ""){ 
          $ResumeUpdate[$key]['resume_id'] = $ResumeInsert[$key]['resume_id']; 
         } 

         $ResumeUpdate[$key]['resume_id']=$Resume['id'][$key]; 
         unset($ResumeInsert[$key]); 
         } 
        else{ 
         $ResumeInsert[$key]['resume_id'] = $GetLastID; 
         $GetLastID++; 
        } 

       $status=$this->Resume_model->ProcessData($idsToDelete,$ResumeUpdate,$user_id,$ResumeInsert,$imgInsert,$imgUpdate); 
       redirect('Resume','refresh'); 

     } 
    } 
?> 

INSERTクエリ(モデル)

function ProcessData($tbl_resumeInsert){ 

     if(!empty($tbl_resumeInsert)) 

    { 

      $this->insert_tbl_resume($user_id,$tbl_resumeInsert); 
    } 

} 

function insert_tbl_resume($id,$arrtbl_resume) 

{ 

     $this->db->insert_batch('tbl_resume', $arrtbl_resume); 

} 
私は $ResumeInsertを印刷するときのみ、最初の Foreach loopのデータが挿入できるフォームを送信しようとしてイムが、それは私だけで最初のforeachループのデータ foreach($this->input->post('Person_id') as $key =>$value) レストforeachループのデータが DBでNULLを出現示し上記のコードでは

助けをお願い致します。 ありがとうございました!

+0

あなたもあなたのhtmlを入れてもいいですか – Brett

答えて

0

関数$this->input->post('something')は、キー「something」を使用して$_POST配列から値を返しています。キー 'something'が存在しない場合、NULLを返します。 (またはCIバージョンのFALSE)

$_POSTは連想配列であり、指定されたキーを持つ項目は1つのみです。キー「PERSON_ID」が一つだけ$_POST配列項目があるように、コード

foreach($this->input->post('Person_id') as $key =>$value) 
{ 
    ... 

は一度だけ実行されます。

フォームhtmlに「Person_id」という名前のフィールドが複数ある場合は、最後のフィールドの値のみがサーバーに送信されます。

+0

私は2番目のforeachループ(** foreach)でecho "xyz"のようなものを印刷すると、HTMLの中にPerson_idという名前のフィールドが1つしかありません。 - >入力 - >ポスト( 'emp_id')$ key => $ value){**}私のブラウザで私は "Xyz"を得ることができますし、もし私が**再開['employer_name'] [$ key ]; **、**私は** "Employer name" **の値を得ることができますが、もし私が**($ ResumeInsert)**を印刷すれば、最初のforeachループのデータだけを取得します –

+0

'foreach($ this-> input - > post( 'emp_id')$ key => $ value) 'は' $ _POST'配列をループしています。 '$ _POST'にキー" emp_id "を持つアイテムが1つしかないので、最初のものが得られます。 '$ this-> input-> post( 'emp_id')'に格納されている値の_data type_が配列で、その配列_から値を抽出したい場合は、 '$ data = $ this-> input - >投稿( 'emp_id');あなたが '$ _POST'配列全体を' $ Resume'に取り込んだので、 'foreach($ resume ['emp_id' ] as $ key => $ value){... ' – DFriend

+0

あなたの質問を編集して'

'のhtmlか入力の構造の説明を含めると、提案を提供する方がはるかに簡単です。 – DFriend

関連する問題