 |
|

ประมาณนี้นะครับ
ถ้าทำการ INSERT มาใหม่ id ก็ต้องไป Update อีกตารางหนึ่งด้วยนะครับ ตามภาพนะครับ
Code (PHP)
$this->upload->initialize($config);
if ($_FILES['file_name']['name']) {
$field_name = 'file_name';
if ($this->upload->do_upload('file_name')){
$gamber = $this->upload->data();
$adddata = array(
'title' => $title,
'description' => $description,
'file_name' => $gamber['file_name'],
'create_by' => $this->vendorId ,
'create_at' => date("Y-m-d H:i:s"),
// 'path' => $config['upload_path'] .'/'
);
$this->db->select_max('id');
$this->db->insert('tbl_teams',$adddata);
$insert2_teacher = $this->db->get('tbl_teams')->row_array();
$teacher_id_list = $insert2_teacher['id'];
foreach ($memberall as $key => $memberall)
{
$data2 = array
(
'id_team' => $teacher_id_list,
'id_member' => $memberall
);
$results = $this->db->insert('tbl_teams_id',$data2);
$this->db->select_max('id_team');
$this->db->where('id');
$insert2_teams = $this->db->get('tbl_teams_id')->row_array();
$teacher_id_teams = $insert2_teams['id_team'];
$data3 = array
(
// 'id' => $id,
'id_teams' => $teacher_id_teams
);
$results = $this->db->update('tbl_member',$data3);
print_r($results);
}
if($results > 0)
{
$this->session->set_flashdata('success', 'Successfully');
}
else
{
$this->session->set_flashdata('error', 'failed');
}
redirect('teams');
}
ที่ผมทำการ foreach เพราะว่า ผมทำเป็น TAG input นะครับ
ใครพอจะมีแนวการเขียนบางนะครับ
Tag : PHP, CodeIgniter
|
|
 |
 |
 |
 |
Date :
2018-10-26 12:52:21 |
By :
1711167185640399 |
View :
717 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |