Skip to content

Instantly share code, notes, and snippets.

@summic
Created January 21, 2012 16:23
Show Gist options
  • Save summic/1653201 to your computer and use it in GitHub Desktop.
Save summic/1653201 to your computer and use it in GitHub Desktop.
view:
<input name="data[datetime][]" value="">
<input name="data[address][]" value="">
Model
<?php
function add($data,$datainfo){
if ($this->db->insert($this->table_name, $data)) {
$oid = $this->db->insert_id();
$total = count($datainfo[opentime]);
for($i=0;$i<$total;$i++)
{
if(isset($datainfo[address][$i]) && !empty($datainfo[address][$i])){
$CourseInfo = array(
'cid' => $oid,
'opentime' => $datainfo[opentime][$i],
'address' => $datainfo[address][$i],
);
if($this->db->insert($this->table_info, $CourseInfo)) {
$id = $this->db->insert_id();
header("Location: /manage/history/list");
} else {
echo '时间地点数据写入失败';//temp
}
}else{
die("地址没有填写");
}
}
} else {
echo 'error';//temp
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment