【发布时间】:2013-08-27 09:53:36
【问题描述】:
table1:subjectmaster
id | subjectcode | subjectname
------------------------------
1 | phy | physics
table2:course master
id | coursecode | coursename
----------------------------
1 | bsc | bachlore of science
table3:examcourse
id | examname | course_code
---------------------------
1 | semester | bsc
table4: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();
}
如果我点击插入表单,它只会在 table3 和 table4
中插入 coursecode 和 examname
但我需要在 table4 中插入coursecode、coursename、subjectcode、subjectname、examname。
如何获取值并将它们插入到表中?
【问题讨论】:
-
$data的结构是什么print_r就好了。
标签: php mysql codeigniter