Clinton Puds
Clinton Puds

Reputation: 11

error getting the array result in Join Query in Codeigniter

Hello this is my query and I have the problem getting the result_array().

This is the error:

Fatal error: Call to a member function result_array() on a non-object in C:\xampp\htdocs\plss\application\views\Admin\post_refresh.php on line 6

<?php 
     $this->db->select('*');
     $this->db->from('forum_thread');
     $this->db->join('useraccount','useraccount.user_id = forum_thread.user_id');
     $post= $this->db->get();  
     foreach($post->result_array()  as $row): ?>    
        <div class="panel panel-default" >
            <div class="panel-body">
               <p>
                  <small>Clinton Puds</small>
                  <small style="float:right;color:#808080;font-size:10px;"><b>Posted Last</b> <?php echo $row['date_last_post']?></small>
                </p>
                <p><?php echo $row['slug'];?></p>
             </div>
             <div class="panel-footer"><small><a href="">Comment</a></small></div>
         </div>     


<?php endforeach ?>

Upvotes: 0

Views: 261

Answers (2)

Shariati
Shariati

Reputation: 119

Try this :

$post->result() as $row

Upvotes: 0

Mudshark
Mudshark

Reputation: 3253

Try this:

 $post = $this->db->get()->result_array();  
 foreach($post as $row): //etc

Upvotes: 0

Related Questions