Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="form-group">
- <label>Question</label>
- <?php if($this->input->post('ques_id')) echo $this->input->post('ques_id'); else echo $data->ques_id; ?>
- <?php $a= json_decode($data->ques_id);echo "<pre>"; print_R($a);"<br>";?>
- <select name="question[]" id="question" multiple="multiple">
- <?php foreach($categories as $ques_id=>$question){ ?>
- <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>
- <?php $value = json_decode($result->value);?>
- <?php } ?>
- </select>
- </div>
- <script>
- $(function() {
- $('#question').change(function() {
- console.log($(this).val());
- }).multipleSelect({
- width: '100%'
- });
- </script>
- public function edit($interview_id) {
- $this->data['categories']=$this->Interview_model->getcategories();
- $where = ' interview_id = ? ';
- $where_data [] = $interview_id;
- if ($this->input->post ()) {
- $update_data = array ();
- $update_data ['name'] = $this->input->post ( 'name' );
- $update_data ['education'] = $this->input->post ( 'education' );
- $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->Interview_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->Interview_model->__update ( 'ph_interview', $update_data, array (
- 'interview_id' => $interview_id
- ) )) {
- $this->session->set_flashdata ( 'error', 'Record couldn'n updated. Please try again.' );
- } else {
- $this->session->set_flashdata ( 'success', 'Interview updated successfully.' );
- //redirect ( 'admin/Interview' );
- }
- }
- $rs = $this->Interview_model->__select ( 'ph_interview', '*', $where, $where_data );
- $result = $rs->result ();
- $this->data ['data'] = $result [0];
- $this->load->view ( 'admin/template/header' );
- $this->load->view ( 'admin/Interview/edit', $this->data );
- $this->load->view ( 'admin/template/footer' );
- }
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Interview_model extends MY_Model {
- public function __construct(){
- parent::__construct();
- }
- public function getinterview_ques($where=array()){
- $category = array();
- $sql ='select * from ph_interview_ques ';
- if(!empty($where)){
- $con='';
- foreach($where as $key=>$value){
- if(!empty($con)){
- $con .=' and ';
- }
- $con .=' '.$key.' ? ';
- }
- $con = trim($con,',');
- $sql .=' where '.$con.' order by question ';
- $rs = $this->db->query($sql,array($where));
- }
- else{
- $sql .=' order by question ';
- $rs = $this->db->query($sql);
- }
- foreach($rs->result() as $result){
- $question[$result->ans] = $result;
- }
- return $question;
- }
- public function getcategories(){
- $sql ="select * from ph_interview_ques order by ques_id asc";
- $rs = $this->db->query($sql);
- foreach($rs->result() as $record ){
- $result[] = $record;
- }
- return $result;
- }
- public function getQuestions($ids){
- $sql ="select * from ph_interview_ques where ques_id in($ids) order by ques_id asc";
- $rs = $this->db->query($sql);
- foreach($rs->result() as $record ){
- $result[] = $record;
- }
- return $result;
- }
- public function getinterviewr($where=array()){
- $category = array();
- $sql ='select * from ph_interview ';
- if(!empty($where)){
- $con='';
- foreach($where as $key=>$value){
- if(!empty($con)){
- $con .=' and ';
- }
- $con .=' '.$key.' ? ';
- }
- $con = trim($con,',');
- $sql .=' where '.$con.' order by name ';
- $rs = $this->db->query($sql,array($where));
- }
- else{
- $sql .=' order by name ';
- $rs = $this->db->query($sql);
- }
- foreach($rs->result() as $result){
- $name[$result->name] = $result;
- }
- return $name;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement