php mysql while loop slideshow


my code is

    <div align="center">
<div id="imgGallary" class="container">
<?php $get_products = $conn->query("SELECT * FROM products"); while ($show_products = $get_products->fetch_assoc()) { ?>
        <h1><?php echo $show_products['name']; ?></h1>
        <img src="img/<?php echo $show_products['img']; ?>" alt="" width="100%" height="300" >
<?php } ?>
            var imgLen = document.getElementById('imgGallary');
            var images = imgLen.getElementsByTagName('img');
            var counter = 1;

            if(counter <= images.length){
                    images[0].src = images[counter].src;

                    if(counter === images.length){
                        counter = 1;

        position: relative;
        width: 90%;
        height: 300px;
        border-radius: 5px;
        border: 1px #00274F solid;
        overflow: hidden;

everything is ok and images working perfect but i cant display others row
like name

<h1><?php echo $show_products['name']; ?></h1>

first item name display and not change just first item name and images ok change


Show us the code that doesn’t work. Right now, there aren’t any <?php echo $show_products['name']; ?>.
<div align=”center”> <div id=”imgGallary” class=”container”> <?php $get_products = $conn->query(“SELECT * FROM products”); while ($show_products = $get_products->fetch_assoc()) { ?> <h1><?php echo $show_products[‘name’]; ?></h1> <img src=”img/<?php echo $show_products[‘img’]; ?>” alt=”” width=”100%” height=”300″ > <?php } ?> </div> </div>
– espooo
4 mins ago
Please update your question to contain all the relevant code instead. It’s pretty unreadable as a comment.
Also, look at the rendered html source and check if the names are outputted correctly (if it’s your HTML/CSS/JS that needs to be changed)