表格1:subjectmaster
id | subjectcode | subjectname
------------------------------
1 | phy | physics
表2:course master
id | coursecode | coursename
----------------------------
1 | bsc | bachlore of science
表3:examcourse
id | examname | course_code
---------------------------
1 | semester | bsc
表4:course_table
id | coursecode | coursename | subjectcode | subjectname | examname
--------------------------------------------------------------------
模型:
function add_record($data)
{
$this->db->insert('examcourse', $data);
$this->db->insert('course_table', $data);
return;
}
控制器:
function create()
{
$j=1;
$createcustomer = $this->input->post('createcustomer');
if( $this->input->post('createcustomer') != false ){
foreach ($createcustomer as $j)
{
$data = array(
'exam_name' => $this->input->post('exam_name_id'.$j),
'course_code' => $this->input->post('course_code_id'.$j)
);
//$course_code= mysql_real_escape_string($_POST["course_code_id".$j]);
$exam_name = $this->input->post('exam_name_id'.$j);
if ($exam_name != ""){
$this->examcourse_model->add_record($data, $exam_name);
}
$j++;
}
}
$this->index();
}
如果我单击插入表单,它只插入coursecode
并examname
在table3和table4
中
,但我需要在table4coursecode
中插入, coursename
, subjectcode
, subjectname
, 。examname
如何获取值并将它们插入表中?