Advertisement
Guest User

Untitled

a guest
May 30th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. <select name="books[]" id="books" multiple="multiple">
  2. <?php foreach($categories as $books_id=>$books){ ?>
  3. <option value="<?php echo $books_id?>"<?php if(($this->input->post('books') && $this->input->post('books') == $books_id) || $data->question == $books_id) echo 'selected';?>>
  4. <?php echo $books->books?></option>
  5. <?php $value = json_decode($result->value);?>
  6. <?php } ?>
  7. </select>
  8.  
  9. add/view->
  10.  
  11. <select name="books[]" id="books" multiple="multiple">
  12. <?php foreach($categories as $books){ ?>
  13. <option value="<?php echo $books->books_id?>" <?php if($this->input->post('books') == $books->books_id) echo 'selected';?>><?php echo $books->books?></option>
  14. <?php $books = json_decode($result->books);?>
  15. <?php } ?>
  16. </select>
  17.  
  18. public function edit($books_id) {
  19. $this->data['categories']=$this->books_model->getcategories();
  20. $where = ' books_id = ? ';
  21. $where_data [] = $books_id;
  22. if ($this->input->post ()) {
  23. $update_data = array ();
  24. $update_data ['ques_id'] = json_encode($this->input->post ( 'question' ));
  25. $update_data ['quotes'] = $this->input->post ( 'quotes' );
  26. $update_data ['comment'] = $this->input->post ( 'comment' );
  27. $update_data ['status'] = ( int ) $this->input->post ( 'status' );
  28. $update_data ['Datetime'] = $this->books_model->getCurrentDatetime ();
  29. if (! $this->input->post ( 'old_image' )) {
  30. $field_name = 'image';
  31. $temp_file_name = $this->file [$field_name] ['name'];
  32. $file_name = time () . '_' . $this->randomString ( 10 ) . '.' . $this->getFileExtension ( $temp_file_name );
  33.  
  34. if (! $this->uploadImage ( $this->upload_path, $file_name, $field_name )) {
  35. $this->session->set_flashdata ( 'error', $this->file_error );
  36. }
  37. $this->createThumbnail ( $this->file_data ['full_path'], $this->upload_path . '/thumb/' . $file_name, 75, 50 );
  38. $update_data ['image'] = $file_name;
  39. }
  40. if (! $this->books_model->__update ( 'ph_books', $update_data, array (
  41. 'books_id' => $books_id
  42. ) )) {
  43. $this->session->set_flashdata ( 'error', 'Record couldn'n updated. Please try again.' );
  44. } else {
  45. $this->session->set_flashdata ( 'success', 'books updated successfully.' );
  46. //redirect ( 'admin/books' );
  47. }
  48. }
  49. $rs = $this->books_model->__select ( 'ph_books', '*', $where, $where_data );
  50. $result = $rs->result ();
  51. $this->data ['data'] = $result [0];
  52.  
  53. $this->load->view ( 'admin/template/header' );
  54. $this->load->view ( 'admin/books/edit', $this->data );
  55. $this->load->view ( 'admin/template/footer' );
  56. }
  57.  
  58.  
  59. function add() {
  60. $this->data['categories']=$this->books_model->getcategories();
  61. if ($this->input->post ()) {
  62. $insert_data = array ();
  63. $insert_data ['ques_id'] = json_encode($this->input->post ( 'question' ));
  64. $insert_data ['quotes'] = $this->input->post ( 'quotes' );
  65. $insert_data ['comment'] = $this->input->post ( 'comment' );
  66. $insert_data ['Datetime'] = $this->books_model->getCurrentDatetime ();
  67. $field_name ='image';
  68. $temp_file_name = $this->file[$field_name]['name'];
  69. $file_name = time().'_'.$this->randomString(10).'.'.$this->getFileExtension($temp_file_name);
  70.  
  71. if(!$this->uploadImage($this->upload_path,$file_name,$field_name)){
  72. $this->session->set_flashdata('error', $this->file_error);
  73. }
  74. else{
  75. $insert_data['image'] = $file_name;
  76. $this->createThumbnail($this->file_data['full_path'], $this->upload_path.'/thumb/'.$file_name,75,50);
  77. if(!$this->books_model->__insert('ph_books',$insert_data)){
  78. $this->session->set_flashdata('error', 'Record couldn'n inserted. Please try again.');
  79. }
  80. else{
  81. $this->session->set_flashdata('success', 'books created.');
  82. //redirect('admin/books');
  83. }
  84. }
  85. } $a=json_encode($this->input->post ( 'question' )); print_R($a);
  86. $this->load->view ( 'admin/template/header' );
  87. $this->load->view ( 'admin/books/add', $this->data );
  88. $this->load->view ( 'admin/template/footer' );
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement