Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > สอบถามผู้รู้ ต้องการเก็บประวัติที่ถูกแก้ไขแล้วนำมาโชว์ ควรทำอย่างไร



 

สอบถามผู้รู้ ต้องการเก็บประวัติที่ถูกแก้ไขแล้วนำมาโชว์ ควรทำอย่างไร

 



Topic : 115262



โพสกระทู้ ( 27 )
บทความ ( 0 )



สถานะออฟไลน์




พอดีว่าทำส่วนที่เก็บข้อมูลที่มีการเปลี่ยนแปลง สามารถทำให้เก็บแล้วนำมาโชว์ได้แล้วแต่ติดปัญหาตรงที่ว่า เมื่อมีการเปลี่ยนข้อมูลใหม่แต่ข้อมูลใหม่ก็ถูกนำมาเก็บไว้ที่ profile_logs ด้วยเหมือนกัน

*** ใช้ CI Framework ในการพัฒนา ***

controllers
Code
function edit_profile($user_id) { // if there is any post param $is_submit = $this->input->post('edit-profile-form'); // validation part // The custom rules 'identity_available' and 'validate_password' can be found in '../libaries/MY_Form_validation.php'. $validation_rules = array( array('field' => 'firstname', 'label' => 'ชื่อจริง', 'rules' => 'required'), array('field' => 'lastname', 'label' => 'นามสกุล', 'rules' => 'required'), array('field' => 'nationality', 'label' => 'เชื้อชาติ', 'rules' => ''), array('field' => 'citizen_id', 'label' => 'เลขที่บัตรประชาชน', 'rules' => 'required'), array('field' => 'email', 'label' => 'email', 'rules' => 'required|valid_email|identity_available'), array('field' => 'primary_lang', 'label' => 'ภาษาหลักที่เข้าใจ', 'rules' => ''), array('field' => 'sex', 'label' => 'เพศ', 'rules' => ''), array('field' => 'phone', 'label' => 'เบอร์โทรศัพท์', 'rules' => ''), array('field' => 'mobile', 'label' => 'เบอร์โทรศัพท์มือถือ', 'rules' => ''), array('field' => 'address1', 'label' => 'ที่อยู่', 'rules' => ''), array('field' => 'address2', 'label' => 'ที่อยู่2', 'rules' => ''), array('field' => 'province', 'label' => 'จังหวัด', 'rules' => ''), array('field' => 'zipcode', 'label' => 'รหัสไปรษณีย์', 'rules' => ''), ); $monk_validation_rule = array( array('field' => 'preceptor', 'label' => 'พระอุปัชฌาย์', 'rules' => ''), array('field' => 'priesthood_year', 'label' => 'ปีที่อุปสมบท', 'rules' => ''), array('field' => 'priest_of_rank', 'label' => 'สมนศักดิ์', 'rules' => ''), //array('field' => 'temple_id', 'label' => 'วัด', 'rules' => 'required'), array('field' => 'monk_name', 'label' => 'ชื่อฉายา', 'rules' => ''), array('field' => 'monk_id', 'label' => 'เลขที่ประจำตัวสงฆ์', 'rules' => ''), ); $layman_validation_rule = array( array('field' => 'education', 'label' => 'ระดับการศึกษา', 'rules' => ''), array('field' => 'field_of_study', 'label' => 'สาขา', 'rules' => ''), array('field' => 'occupation', 'label' => 'อาชีพ', 'rules' => ''), array('field' => 'educational_institution', 'สถาบันการศึกษา' => 'อาชีพ', 'rules' => ''), ); if (isset($is_submit)) { // create user and profile $result = false; // set validation rule $profile_type = $this->input->post('profile_type'); if ($profile_type == 1) { $this->form_validation->set_rules(array_merge($validation_rules, $layman_validation_rule)); } else if ($profile_type == 2) { $this->form_validation->set_rules(array_merge($validation_rules, $monk_validation_rule)); } // Run the validation. if ($this->form_validation->run()) { $result = $this->_prepare_data_and_update($user_id); } else { $this->data['error'] = validation_errors(); } // create a user if($result) { $this->session->set_flashdata('message', 'ทำการเปลี่ยนข้อมูลเรียบร้อยแล้ว'); //$this->send_change_password_confirmation(); redirect("admin/users/edit_profile/".$user_id, 'refresh'); } } $user = User::find($user_id); $this->data['user_id'] = $user_id; $this->data['staff'] = $user; $this->data['profile'] = $user->profile; $this->data['email'] = $user->uacc_email; $this->data['firstname'] = $user->profile->firstname; $this->data['lastname'] = $user->profile->lastname; $this->data['addresses'] = $user->profile->addresses; $this->data['secondary_langs'] = $user->profile->secondary_languages; $this->data['profilelogs'] = Profilelog::all(); //ส่วนนี้จะดึงเอาข้อมูลที่ถูกแก้ไขแล้ว ที่ถูกเก็บไว้ที่ DB->profile_logs ดึงมาโชว์ทั้งหมด // generate dropdown lists $this->data['profile_type_list'] = ProfileType::get_select_list(); $this->data['sex_list'] = Sex::get_select_list(); $this->data['nationality_list'] = Nationality::get_select_list(); $this->data['primary_lang_list'] = Language::get_select_list(); $this->data['occupation_list'] = Occupation::get_select_list(); $this->data['secondary_lang_list'] = Language::get_select_list(); unset($this->data['secondary_lang_list'][""]); $this->data['province_list'] = Province::get_select_list(); $this->data['priest_of_rank_list'] = PriestOfRank::get_select_list(); $this->data['temple_list'] = Temple::get_select_list(); $this->data['title'] = "แก้ไขประวัติของ".$user->profile->firstname.' '.$user->profile->lastname; // style for this page $this->data['page_styles'] = array("bootstrap-datetimepicker.min.css"); // script for this page $this->data['page_scripts'] = array("moment.js", "bootstrap-datetimepicker.min.js", "admin.edit.user.profile.js"); // $this->data['inpage_script'] = "bookings/_calendar_js"; // specify view $this->data['view_name'] = "/admin/users/edit_profile"; $this->load->view('layouts/main', $this->data); } controllers private function _prepare_data_and_update($user_id) { $user = User::find($user_id); $log_attribute = new Profilelog(); $log_attribute->profiles_id = $this->input->post('id'); $log_attribute->citizen_id = $this->input->post('citizen_id'); $log_attribute->firstname = $this->input->post('firstname'); $log_attribute->lastname = $this->input->post('lastname'); $log_attribute->save(); //ส่วนนี้เป็นข้อมูลที่จะจัดเก็บแล้วนำมาแสดง


ตอนกรอกข้อมูล
input

ผลลัพธ์
output


***ในส่วนของผลลัพธ์ไม่อยากให้โชว์ข้อมูลที่พึ่งกรอกไปต้องทำยังไงค่ะ แนะนำด้วยค่ะ***



Tag : PHP, MySQL









ประวัติการแก้ไข
2015-03-20 10:26:40
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-03-20 10:25:01 By : Ampreaw View : 851 Reply : 5
 

 

No. 1



โพสกระทู้ ( 27 )
บทความ ( 0 )



สถานะออฟไลน์


ใช้ CI Framework ในการเขียน






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-03-20 10:25:56 By : Ampreaw
 


 

No. 2



โพสกระทู้ ( 1,150 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ก่อนจะทำการ edit อะคับ

ให้ select ข้อมูลเก่าออกมาก่อน เก็บไว้ใน ตัวแปร $a

แล้ว ค่อยไป edit ค่าที่ส่งมา

แล้วเอา $a ไป insert ใน table log
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-03-20 10:44:55 By : progamer2000
 

 

No. 3



โพสกระทู้ ( 27 )
บทความ ( 0 )



สถานะออฟไลน์


ถ้าไม่เป็นการรบกวน คุณ Iprogamer2000 ช่วยเขียนให้หน่อยได้ไหมค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-03-20 11:02:35 By : Ampreaw
 


 

No. 4



โพสกระทู้ ( 27 )
บทความ ( 0 )



สถานะออฟไลน์


$log_attribute = new Profilelog();
$log_attribute->profiles_id = $user_id;
$log_attribute->citizen_id = $this->input->post('citizen_id');
$log_attribute->firstname = $this->input->post('firstname');
$log_attribute->lastname = $this->input->post('lastname');
$log_attribute->save();

ในส่วนนี้มีการเก็บข้อมูลเก่าไปไว้ที่ profile_log แล้วก่อนที่จะมีการ edit อ่ะค่ะ
แต่มันก็เก็บข้อมูลใหม่ลงไปด้วย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-03-20 11:28:05 By : Sub.P
 


 

No. 5



โพสกระทู้ ( 9,553 )
บทความ ( 2 )



สถานะออฟไลน์


Code (PHP)
if ($this->form_validation->run())
      {
        $result = $this->_prepare_data_and_update($user_id);
      }
      else
      {
        $this->data['error'] = validation_errors();
      }


คำสั่งชุดข้างบนคงต้อเปลี่ยน และ แก้ไขฟังก์ชั่นใหม่
แยก ฟังก์ชั่น _prepare_data_and_update($user_id);
ใหเป็น 3 ส่วน
Code (PHP)
private function _prepare_data( $user_id ){
     //............................
}
private function _update($user_id){
     //.................
}
private function _get_old_result( $user_id){
     //.................
}


แล้วก็เลือกใช้เอาตามความเหมาะสม ฟังก์ชี่นเก่าที่ทำ มันupdate และส่งคิวรี่ล่าสุดออกมา
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-03-20 11:42:50 By : Chaidhanan
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามผู้รู้ ต้องการเก็บประวัติที่ถูกแก้ไขแล้วนำมาโชว์ ควรทำอย่างไร
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่