load->model('Faq_model'); } function list_faq() { if($this->session->userdata('id')==""){redirect('admin/login');} $data['faq']=$this->Faq_model->list_faq(); $this->load->view('admin/faq/list',$data); } function add_faq() { if($this->session->userdata('id')==""){redirect('admin/login');} if($this->input->post('add')) { $Question=$this->input->post('Question'); $Answer=$this->input->post('Answer'); $table="faq"; //echo $ledgername; $values=array('question'=>$Question, 'answer'=>$Answer, 'cdate'=>date('Y-m-d H:i:s'), 'status'=>1); $result=$this->commonsql_model->insert_table($table,$values); if($result) { $this->session->set_userdata('suc','successfully added'); redirect('admin/faq'); } else { $this->session->set_userdata('err','Please try again'); redirect('admin/faq'); } } $this->load->view('admin/faq/add'); } function edit_faq($id) { if($this->session->userdata('id')==""){redirect('admin/login');} if($this->input->post('edit')) { $Question=$this->input->post('Question'); $Answer=$this->input->post('Answer'); $table="faq"; //echo $ledgername; $values=array('question'=>$Question, 'answer'=>$Answer, 'udate'=>date('Y-m-d H:i:s'), 'status'=>1); $where=array("id"=>$id); $result=$this->commonsql_model->updatetable($table,$where,$values); if($result) { $this->session->set_userdata('suc','successfully updated'); redirect('admin/faq'); } else { $this->session->set_userdata('err','Please try again'); redirect('admin/faq'); } } $data['faq']=$this->Faq_model->list_faq($id); $this->load->view('admin/faq/edit',$data); } function check_uncheck_faq() { $id=$_POST['id']; $value=$_POST['val']; $tblname="faq"; $where=array('id'=>$id); $update=array('status'=>$value); $results=$this->commonsql_model->updateTable($tblname,$where,$update); if($results) { echo "1"; } else { echo "2"; } } } ?>