williamh69 Posted January 13, 2020 Share Posted January 13, 2020 Hi guys i am populating products from db, but the images does not showing sequentially, there are gaps between images ,,how i can fix this this is my code: <?php $query = "SELECT * FROM products"; $select_products = mysqli_query($connection, $query); while ($row = mysqli_fetch_assoc($select_products)){ $product_id = $row['product_id']; $product_title = $row['product_title']; $product_image = $row['product_image']; $product_description = $row['product_description']; $product_quantity = $row['product_quantity']; $product_price = $row['product_price']; $short_desc = $row['short_desc']; ?> <div class="col-sm-4 col-lg-4 col-md-4"> <div class="thumbnail"> <img src="./images/<?php echo $product_image ?>" width="478" height="1034" alt=""> <div class="caption"> <h4 class="pull-right">$<?php echo $product_price ?></h4> <h4><a href="#"><?php echo $product_title ?></a> </h4> <p><?php echo $product_description ?>.</p> </div> <div class="ratings"> <p class="pull-right">18 reviews</p> <p> <span class="glyphicon glyphicon-star"></span> <span class="glyphicon glyphicon-star"></span> <span class="glyphicon glyphicon-star"></span> <span class="glyphicon glyphicon-star"></span> <span class="glyphicon glyphicon-star-empty"></span> </p> </div> </div> </div> <?php } ?> Quote Link to comment Share on other sites More sharing options...
MarkPhp2 Posted January 25, 2020 Share Posted January 25, 2020 (edited) <img src="./images/<?php echo $product_image ?>" width="478" height="1034" alt=""> <?php echo $product_image ?> -make sure that name in db and acctual name of the image are the same do you keep images in db or just a path? Edited January 25, 2020 by MarkPhp2 Quote Link to comment Share on other sites More sharing options...
Strider64 Posted January 25, 2020 Share Posted January 25, 2020 (edited) I personally find it easier to store the path and the filename in the database table, for example - assets/large/img-photos-1554932472.jpg. Then I simply do <img src="<?php echo $image ?>" width="478" height="1034" alt=""> Edited January 25, 2020 by Strider64 Added Example Quote Link to comment Share on other sites More sharing options...
MarkPhp2 Posted February 2, 2020 Share Posted February 2, 2020 hmm thats weird everything should be just fine. I will send you my code so maybe you can use it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.