PHP code is:
class Gallery{
public function get_images(){
global $pdo;
$query = $pdo->prepare('SELECT * FROM gallerys order by id desc');
$query->execute();
return $query->fetchAll(PDO::FETCH_ASSOC);
}
public function fetch_data($pid){
global $pdo;
$query = $pdo->prepare('SELECT * FROM gallerys where id = ? order by id desc');
$query->BindValue(1,$pid);
$query->execute();
return $query->fetch();
}
}
HTML code is:
$post = new Gallery;
$check = new Gallery;
$galery = $post->get_images();
<?php foreach($galery as $post){?>
<div class="fw-carousel fl-wrap full-height lightgallery">
<div class="slick-slide-item">
<div class="box-item">
<img src="../asset/<?php echo $post['image'];?>" alt="">
<a href="../asset/<?php echo $post['image']?>" class="gal-link popup-image"><i class="fa fa-search" ></i></a>
</div>
</div>
</div>
<?php }?>
Database structure:
---id---name---user---post_date---image---
When user post something and put 3 images into table gallerys
on column user```` will be places
$_SESSION['user_id'];and with that i will retrieve images by
user_id``` now i get only 1 image not all example 3 or 5 or 10...
When user upload example 3 or 5 images into database and want to view his upload, with this code they will get only 1 image, not all image what he upload. I don't get where is the problem in this script.
Any help?