Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
I can't get data and post it in my html

model

public function getPost(){
    $this->db->select('post_title', 'post_auth', 'post_content');
    $this->db->from('post');
    $query = $this->db->get();
    return $query->result_array();
}

controller

public function index(){
    $this->load->model('swmodel');
    $data['posts'] = $this->swmodel->getPost();
    $this->load->view('dashBoard', $data);
}

How can I transfer data in my view?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Honestly I can't say you why, but for some reason in CodeIgniter 3 you have to store the result or return of your function in a variable and then that variable assign it within the array based value you pass to your view as $this->load->view('dashBoard', $data);.

You need to check does exist a view called dashBoard? and where is it?

So you can try with something like:

public function index() {
  $this->load->model('posts_model');
  // Get your posts, store them in $posts.
  $posts = $this->posts_model->getPost();
  // Assign your $posts to your $data.
  $data['posts'] = $posts;
  // Pass your $data when you load the view.
  $this->load->view('dashBoard', $data);
}

And then in your view you can easily access to the passed data as $posts.

# dashBoard.php
<?php var_dump($posts); ?>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!