Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <select name="books[]" id="books" multiple="multiple">
- <?php foreach($categories as $books_id=>$books){ ?>
- <option value="<?php echo $books_id?>"<?php if(($this->input->post('books') && $this->input->post('books') == $books_id) || $data->question == $books_id) echo 'selected';?>>
- <?php echo $books->books?></option>
- <?php $value = json_decode($result->value);?>
- <?php } ?>
- </select>
- add/view->
- <select name="books[]" id="books" multiple="multiple">
- <?php foreach($categories as $books){ ?>
- <option value="<?php echo $books->books_id?>" <?php if($this->input->post('books') == $books->books_id) echo 'selected';?>><?php echo $books->books?></option>
- <?php $books = json_decode($result->books);?>
- <?php } ?>
- </select>
- public function edit($books_id) {
- $this->data['categories']=$this->books_model->getcategories();
- $where = ' books_id = ? ';
- $where_data [] = $books_id;
- if ($this->input->post ()) {
- $update_data = array ();
- $update_data ['ques_id'] = json_encode($this->input->post ( 'question' ));
- $update_data ['quotes'] = $this->input->post ( 'quotes' );
- $update_data ['comment'] = $this->input->post ( 'comment' );
- $update_data ['status'] = ( int ) $this->input->post ( 'status' );
- $update_data ['Datetime'] = $this->books_model->getCurrentDatetime ();
- if (! $this->input->post ( 'old_image' )) {
- $field_name = 'image';
- $temp_file_name = $this->file [$field_name] ['name'];
- $file_name = time () . '_' . $this->randomString ( 10 ) . '.' . $this->getFileExtension ( $temp_file_name );
- if (! $this->uploadImage ( $this->upload_path, $file_name, $field_name )) {
- $this->session->set_flashdata ( 'error', $this->file_error );
- }
- $this->createThumbnail ( $this->file_data ['full_path'], $this->upload_path . '/thumb/' . $file_name, 75, 50 );
- $update_data ['image'] = $file_name;
- }
- if (! $this->books_model->__update ( 'ph_books', $update_data, array (
- 'books_id' => $books_id
- ) )) {
- $this->session->set_flashdata ( 'error', 'Record couldn'n updated. Please try again.' );
- } else {
- $this->session->set_flashdata ( 'success', 'books updated successfully.' );
- //redirect ( 'admin/books' );
- }
- }
- $rs = $this->books_model->__select ( 'ph_books', '*', $where, $where_data );
- $result = $rs->result ();
- $this->data ['data'] = $result [0];
- $this->load->view ( 'admin/template/header' );
- $this->load->view ( 'admin/books/edit', $this->data );
- $this->load->view ( 'admin/template/footer' );
- }
- function add() {
- $this->data['categories']=$this->books_model->getcategories();
- if ($this->input->post ()) {
- $insert_data = array ();
- $insert_data ['ques_id'] = json_encode($this->input->post ( 'question' ));
- $insert_data ['quotes'] = $this->input->post ( 'quotes' );
- $insert_data ['comment'] = $this->input->post ( 'comment' );
- $insert_data ['Datetime'] = $this->books_model->getCurrentDatetime ();
- $field_name ='image';
- $temp_file_name = $this->file[$field_name]['name'];
- $file_name = time().'_'.$this->randomString(10).'.'.$this->getFileExtension($temp_file_name);
- if(!$this->uploadImage($this->upload_path,$file_name,$field_name)){
- $this->session->set_flashdata('error', $this->file_error);
- }
- else{
- $insert_data['image'] = $file_name;
- $this->createThumbnail($this->file_data['full_path'], $this->upload_path.'/thumb/'.$file_name,75,50);
- if(!$this->books_model->__insert('ph_books',$insert_data)){
- $this->session->set_flashdata('error', 'Record couldn'n inserted. Please try again.');
- }
- else{
- $this->session->set_flashdata('success', 'books created.');
- //redirect('admin/books');
- }
- }
- } $a=json_encode($this->input->post ( 'question' )); print_R($a);
- $this->load->view ( 'admin/template/header' );
- $this->load->view ( 'admin/books/add', $this->data );
- $this->load->view ( 'admin/template/footer' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement