Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8305929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:13:40+00:00 2026-06-08T18:13:40+00:00

I am retrieving a column from my database and storing that values in an

  • 0

I am retrieving a column from my database and storing that values in an array in my controller.
I am passing that array to the view page, and displaying that values to the user.
All things upto this are working fine.
But the problem is when I am refreshing the page its not showing the values obtained by the controller from the model and just showing blank page..\
I also tried to store the value in a session and use that value but that doesn’t seem to work for me.. 🙁
here is my controller code :-

function full_post_view(){
            $data= array(
                'ticket_id' => $this->input->post('ticket_id')
            ); 
            $this->session->set_userdata($data); 
            $ticket_id = ($this->input->post('ticket_id')) ? $this->input->post('ticket_id') : $this->session->userdata('ticket_id');
//                $post_content = $this->session->userdata('post_content');
            echo $ticket_id;
            $this->load->model('helpdesk_model');
            $all_comments = $this->helpdesk_model->fetchComments($ticket_id);
            $is_post_closed = $this->helpdesk_model->fetchPostStatus($ticket_id);
            if($all_comments->num_rows > 0)  {
                foreach ($all_comments->result() as $comments_value) {
                    $comments = $comments_value->comments;
                }
                $count=1;
                Template::set('all_comments',$all_comments);
                Template::set_view('helpdesk/full_post_view');
            }
            else {
                $count=0;
                Template::set('post_content',$this->input->post('post_content'));
            }                 
            Template::set('is_post_close',$is_post_closed);
            Template::set('ticket_id',$ticket_id);
            Template::set('is_post_closed',$is_post_closed);
            Template::set('post_content',$post_content);
            Template::set('count',$count);                
            Template::set('is_post_closed',$is_post_closed);                
            Template::render();
    }

here is my view :-

<?php $post=Template::get('post_content'); ?>
<?php  $ticket_id=Template::get('ticket_id'); ?>
<?php  $is_close = Template::get('is_close'); ?>
<h4>Your Problem :- </h4>
<?php echo $post; ?>
<hr/>
<?php foreach ($is_post_closed->result() as  $value) {
    $is_close = $value->is_close;
} ?>
<?php if(Template::get('count') > 0) : ?>
    <?php foreach($all_comments->result_array() as $commentsRow) : ?>
        <?php echo word_wrap($commentsRow['comments'],15); ?>
    <?php echo " by->"; ?>
    <?php echo $commentsRow['username']; ?>
    <?php echo $commentsRow['role_name']; ?>
    <hr/>
<?php endforeach; ?>
<?php else : ?>
    <br/>
    No Comments Yet
<?php endif; ?>
<?php if($is_close == 0 ) : ?>
    <?php echo form_open('helpdesk/newComment'); ?>
    <?php echo form_hidden('ticket_id',$ticket_id); ?>
    <?php  echo form_hidden('post_content', $post); ?>
    <?php echo form_textarea('comment_from_user'); ?>
    <?php echo form_submit('submit', 'Comment '); ?>
    <?php echo form_close(); ?>
<?php endif; ?>
<?php if($is_close==0) : ?>
<?php echo form_open('helpdesk/closePost'); ?>
<?php echo form_hidden('ticket_id', $ticket_id); ?>
<?php  echo form_hidden('post_content', $post); ?>  
<?php echo form_submit('submit','close post'); ?>
<?php echo form_close(); ?>
<?php else : ?>
<?php echo form_open('helpdesk/reopenPost'); ?>
<?php echo form_hidden('ticket_id', $ticket_id); ?>
<?php echo form_submit('submit','Reopen post'); ?>
<?php echo form_close(); ?>
<?php endif; ?>

Edit :
I want to ask that how to load the database content again to the view when user refreshes the page.

Edited my Controller and view code

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:13:41+00:00Added an answer on June 8, 2026 at 6:13 pm

    Solved 🙂
    the problem was when I was refreshing the page, ticket_id was set to 0 and that value was passed as a post .
    So the session value was the new ticket_id i.e., 0 and so it was displaying nothing..
    I did this:-

    if(isset($_POST['ticket_id'])) {
    $data= array(
    'ticket_id' => $this->input->post('ticket_id'),
                    'post_content' => $this->input->post('post_content')
                 ); 
                 $this->session->set_userdata($data); 
    }
            $ticket_id =$this->session->userdata('ticket_id');
            $post_content =$this->session->userdata('post_content');
    

    i.e., I am storing ticket_id in session when post in set i.e., for the first time. When page is refreshed next time ticket_id post is not set and data is taken from session.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am retrieving an array values from database which save multi dimensional array..i want
I'm retrieving only dates from database from a DATETIME column named Date. Using DATE(Date)
I am trying to implement security by retrieving user and roles from database. With
When retrieving values from a DataRow is it better to use the column name
I'm retrieving data from a MySQL table and displaying it on a webpage using
I'm retrieving a signed int from a SQL Server database and need to convert
I'm retrieving a set of location names from a MySQL database using PHP and
I am retrieving 3 fields from a database, and by default, only the username
Having trouble with AR 2.3.5, e.g.: users = User.all( :select => u.id, c.user_id, :from
I am trying to write a query for retrieving data from SQLite database. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.