CodeIgniter Display data from database to view -


i trying data database , pass view create in model function getting data, , it's that

   public function get_data_from_db(){         $query = $this->db->get('posts');         return $query->result_array();     } 

and in view create foreach loop like:

<h6>mjesto odredista:  <?php if($posts): ?> <?php foreach ($posts $post): ?> <div class="well"> <h5><?php echo $posts['mjestoodredista'];?> </div> <?php endforeach;?>         <?php  else : ?>  <?php endif;?> </h6> 

and data view passed 10 time:

screenshot

can explane did make mistake ?

your h5 tag contains $posts, should $post.

<h6>mjesto odredista:  <?php if($posts): ?> <?php foreach ($posts $post): ?> <div class="well"> <h5><?php echo $post['mjestoodredista'];?> </div> <?php endforeach;?>         <?php  else : ?>  <?php endif;?> </h6> 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -