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:
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
Post a Comment