Jump to content

Recommended Posts

Posted
<!DOCTYPE html> 
<html> 
<head> 
<!-- CSS --> 
<link rel="stylesheet" href="https://unpkg.com/flickity@2/dist/flickity.min.css"> 
<!-- JavaScript --> 
<script src="https://unpkg.com/flickity@2/dist/flickity.pkgd.min.js"></script> 
</head> 
<body> 
 
<?php 
$db = mysqli_connect("localhost", "root", "", "post_images");       
$result = mysqli_query($db, "SELECT * FROM posts"); 
?> 
 
<?php while ($row = mysqli_fetch_array($result)) : ?> 
 
    <div class="post_container">$row['post_title']; 
 
        <?php $resultx = mysqli_query($db, "SELECT img_file, img_title FROM images WHERE post_id = " .$row['id_post']); ?> 
 
        <?php if (mysqli_num_rows($resultx) == 1) : ?> 
 
        <div class="image_container"> 
 
            <div class="post_image_displayer"> 
 
                <?php while ($rowx = mysqli_fetch_array($resultx)) : ?> 
                <img src='../folder_image_uploads/<?php echo $rowx['img_file']; ?>'><?php echo $rowx['img_title']; ?> 
                <?php endwhile; ?> 
 
            </div> 
 
        </div> 
 
        <?php elseif(mysqli_num_rows($resultx) > 1) : ?> 
 
            <div class="main-carousel" data-flickity='{ "cellAlign": "left", "contain": true }'> 
 
                <?php while ($rowx = mysqli_fetch_array($resultx)) : ?> 
                <div class="carousel-cell"><img src='../folder_image_uploads/<?php echo $rowx['img_file']; ?>' ></div> 
                <?php endwhile; ?> 
 
            </div> 
 
        <?php endif; ?> 
 
    </div> 
 
<?php endwhile; ?> 
 
</body> 
</html> 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...