class Input extends Controller{
function Input(){
parent::Controller();
$this->load->model('input_model');
$this->load->helper('url');
}
function index(){
$data['year']=$_POST['year'];
$data['month']=$_POST['month'];
$data['table']=$data['year'].$data['month'];
if ($this->db->table_exists($data['table']))
{
//$data['table']='It work!';
// some code...
}
else
{
$this->input_model->create_table($data['table']);
}
$this->load->view('input_view',$data);
}
function add(){
$data['table']=$_POST['table'];
$data['add']=$_POST['add'];
$data['title']=$_POST['title'];
$data['describe']=$_POST['describe'];
$data['url']=$_POST['url'];
$insert=$this->input_model->add_data($data);
if($insert==1){
echo "<script language='JavaScript'>alert('成功');parent.parent.location.reload(); </script>";
}
else{
//如果插入失败,则报错
echo "<script language='JavaScript'>alert('失败');</script>";
$this->load->view('input_view');
}
}
}