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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -