Not able to display the comment of the status |
## Display Comments for status in Code Igniter##
--------------------------- VIEW-- filename:STATUS.php -------------------------------------------------------------------------------- $this->load->helper('form'); $this->load->helper('date'); //dispays the status foreach ($result as $row) { echo $status = $row->Status; $statusID=$row->id;//need to fetch this ID and pull it back to the controller } //to fetch the comment foreach ($comment_data as $row) { echo $status_comment = $row->status_comment; } //to add comment form_open('site/insert_comment');?> <input class="form-control" placeholder="Add a comment.." type="text"> <input type="submit" name="submit"/> <?php form_close(); ?> -------------------------------------------------- Controller -- filename ![]() --------------------------------------------------- class site extends CI_Controller { public function status(){ $this->load->model('model_get'); $data['result']= $this->model_get->get_all_status(); $this->load->view('status',$data); $this->load_comment($statusID); } public function load_comment($statusID){ $this->load->model('model_get'); $data['comment_data']= $this->model_get->load_comments($statusID); $this->load->view('status',$data); } } ---------------------------------------------------------------- MODEL - File Name: model_get.php ----------------------------------------------------------------- <?php class model_get extends CI_Controller { function get_all_status(){ $query= $this->db->get('status'); return $query->result(); } function load_comments($statusID){ $query= $this->db->get_where("comment",array('status_id'=>$statusID)); return $query->result(); } } |
Welcome Guest, Not a member yet? Register Sign In |