Advertisement
Guest User

Untitled

a guest
May 31st, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.29 KB | None | 0 0
  1. <div class="form-group">
  2. <label>Question</label>
  3. <?php if($this->input->post('ques_id')) echo $this->input->post('ques_id'); else echo $data->ques_id; ?>
  4. <?php $a= json_decode($data->ques_id);echo "<pre>"; print_R($a);"<br>";?>
  5. <select name="question[]" id="question" multiple="multiple">
  6. <?php foreach($categories as $ques_id=>$question){ ?>
  7. <option value="<?php echo $ques_id?>" <?php if(($this->input->post('question') && $this->input->post('question') == $ques_id) || $data->question == $ques_id) echo 'selected';?>> <?php echo $question->question?></option>
  8. <?php $value = json_decode($result->value);?>
  9. <?php } ?>
  10. </select>
  11. </div>
  12. <script>
  13. $(function() {
  14. $('#question').change(function() {
  15. console.log($(this).val());
  16. }).multipleSelect({
  17. width: '100%'
  18. });
  19. </script>
  20.  
  21. public function edit($interview_id) {
  22. $this->data['categories']=$this->Interview_model->getcategories();
  23. $where = ' interview_id = ? ';
  24. $where_data [] = $interview_id;
  25. if ($this->input->post ()) {
  26. $update_data = array ();
  27. $update_data ['name'] = $this->input->post ( 'name' );
  28. $update_data ['education'] = $this->input->post ( 'education' );
  29. $update_data ['ques_id'] = json_encode($this->input->post ( 'question' ));
  30. $update_data ['quotes'] = $this->input->post ( 'quotes' );
  31. $update_data ['comment'] = $this->input->post ( 'comment' );
  32. $update_data ['status'] = ( int ) $this->input->post ( 'status' );
  33. $update_data ['Datetime'] = $this->Interview_model->getCurrentDatetime ();
  34. if (! $this->input->post ( 'old_image' )) {
  35. $field_name = 'image';
  36. $temp_file_name = $this->file [$field_name] ['name'];
  37. $file_name = time () . '_' . $this->randomString ( 10 ) . '.' . $this->getFileExtension ( $temp_file_name );
  38.  
  39. if (! $this->uploadImage ( $this->upload_path, $file_name, $field_name )) {
  40. $this->session->set_flashdata ( 'error', $this->file_error );
  41. }
  42. $this->createThumbnail ( $this->file_data ['full_path'], $this->upload_path . '/thumb/' . $file_name, 75, 50 );
  43. $update_data ['image'] = $file_name;
  44. }
  45. if (! $this->Interview_model->__update ( 'ph_interview', $update_data, array (
  46. 'interview_id' => $interview_id
  47. ) )) {
  48. $this->session->set_flashdata ( 'error', 'Record couldn'n updated. Please try again.' );
  49. } else {
  50. $this->session->set_flashdata ( 'success', 'Interview updated successfully.' );
  51. //redirect ( 'admin/Interview' );
  52. }
  53. }
  54. $rs = $this->Interview_model->__select ( 'ph_interview', '*', $where, $where_data );
  55. $result = $rs->result ();
  56. $this->data ['data'] = $result [0];
  57. $this->load->view ( 'admin/template/header' );
  58. $this->load->view ( 'admin/Interview/edit', $this->data );
  59. $this->load->view ( 'admin/template/footer' );
  60. }
  61.  
  62. <?php
  63. defined('BASEPATH') OR exit('No direct script access allowed');
  64.  
  65. class Interview_model extends MY_Model {
  66.  
  67. public function __construct(){
  68. parent::__construct();
  69. }
  70. public function getinterview_ques($where=array()){
  71. $category = array();
  72. $sql ='select * from ph_interview_ques ';
  73. if(!empty($where)){
  74. $con='';
  75. foreach($where as $key=>$value){
  76. if(!empty($con)){
  77. $con .=' and ';
  78. }
  79. $con .=' '.$key.' ? ';
  80. }
  81. $con = trim($con,',');
  82. $sql .=' where '.$con.' order by question ';
  83. $rs = $this->db->query($sql,array($where));
  84. }
  85. else{
  86. $sql .=' order by question ';
  87. $rs = $this->db->query($sql);
  88. }
  89. foreach($rs->result() as $result){
  90. $question[$result->ans] = $result;
  91. }
  92. return $question;
  93. }
  94.  
  95. public function getcategories(){
  96. $sql ="select * from ph_interview_ques order by ques_id asc";
  97. $rs = $this->db->query($sql);
  98. foreach($rs->result() as $record ){
  99. $result[] = $record;
  100. }
  101. return $result;
  102. }
  103.  
  104. public function getQuestions($ids){
  105. $sql ="select * from ph_interview_ques where ques_id in($ids) order by ques_id asc";
  106. $rs = $this->db->query($sql);
  107. foreach($rs->result() as $record ){
  108. $result[] = $record;
  109. }
  110. return $result;
  111. }
  112. public function getinterviewr($where=array()){
  113. $category = array();
  114. $sql ='select * from ph_interview ';
  115. if(!empty($where)){
  116. $con='';
  117. foreach($where as $key=>$value){
  118. if(!empty($con)){
  119. $con .=' and ';
  120. }
  121. $con .=' '.$key.' ? ';
  122. }
  123. $con = trim($con,',');
  124. $sql .=' where '.$con.' order by name ';
  125. $rs = $this->db->query($sql,array($where));
  126. }
  127. else{
  128. $sql .=' order by name ';
  129. $rs = $this->db->query($sql);
  130. }
  131. foreach($rs->result() as $result){
  132. $name[$result->name] = $result;
  133. }
  134. return $name;
  135. }
  136.  
  137. }
  138. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement