php - Displaying images and their accompanying information from a database with codeigniter -
ok im uploading images folder on server, , trying re-display them information.
this function in model using pull info:
public function pull_all(){ $this->db->select('file_name, file_type, full_path, image_type'); $query = $this->db->get('img'); $dbinfo = $query->result_array(); return $dbinfo; }
the controller implements function so:
function show_all(){ $this->load->model('image_work'); $data = array('dbinfo' => $this->image_work->pull_all()); $data['title'] = "uploads"; $this->load->view('templates/header', $data); $this->load->view('show_all',$data); $this->load->view('templates/footer', $data); }
the problem iv been having in view. want each image shown info in format:
<ul class="thumbnails"> <li class="span3"> <div class="thumbnail"> <img src="$location_stored_in_database"/> <h3>$image_name</h3> <p>$image_type</p> <p>$image_size</p> <p>$image_dimensions</p> </div> </li>
iv tried many different ways example nested foreach statements, cant seem right. appreciated.
thanks
you can this:
<?php foreach($dbinfo $image): ?> <ul class="thumbnails"> <li class="span3"> <div class="thumbnail"> <img src="<?php echo $image['full_path']; ?>"/> <h3><?php echo $image['image_name']; ?></h3> <p><?php echo $image['image_type']; ?></p> <p><?php echo $image['image_size']; ?></p> <p><?php echo $image['image_dimensions']; ?></p> </div> </li> <?php endforeach; ?>
Comments
Post a Comment