php - Place 3 box in a single row -


i fetching data images database , wish place maximum 3 images in single row , these images have hover effect on them working fine

problem facing if using code display static images working fine if fetch data database not displaying properly. want display images in form

1st_image  2nd_image  3rd_image    4th_image  5th_image  6th_image   7th_image .. , on 

but getting images in form

1st_image   2nd_image   3rd_image    4th_image   5th_image   6th_image 

the code have is

code of front page is

<?php $sql = "select * category"; $result = mysqli_query($con, $sql); if (mysqli_num_rows($result) > 0)      {         while($row = mysqli_fetch_assoc($result))              {                 $catname=$row["catname"];                 $catdesc=$row["catdesc"];                 $catpic=$row["catpic"];                 $id=$row["id"];  ?>                 <div id="effect-2" class="effects clearfix">                     <div class="img">                         <img src="<? echo $catpic; ?>" alt="">                             <div class="overlay">                                 <a href="#" class="">content</a>                                 <a class="close-overlay hidden">x</a>                             </div>                     </div>                 </div>             <?}     }?>  

code on css page

nav ul {   list-style-type: none;   margin: 0 0 30px 0;   padding: 0;   text-align: center; } nav ul li {   display: inline-block;   margin-bottom: 4px; } nav ul li {   display: block;   padding: 5px 20px;   color: #fff;   background-color: #32c896; } nav ul li a:hover {   color: #fff;   background-color: #238b68; } nav ul li a.active {   color: #fff;   background-color: #238b68; }   .effects {   padding-left: 15px; } .effects .img {   position: relative;   float: left;   margin-bottom: 5px;   width: 25%;   overflow: hidden; } .effects .img:nth-child(n) {   margin-right: 5px; } .effects .img:first-child {   margin-left: -15px; } .effects .img:last-child {   margin-right: 0; } .effects .img img {   display: block;   margin: 0;   padding: 0;   max-width: 100%;   height: auto; }  .overlay {   display: block;   position: absolute;   z-index: 20;   background: rgba(0, 0, 0, 0.8);   overflow: hidden;   -webkit-transition: 0.5s;   -moz-transition: 0.5s;   -o-transition: 0.5s;   transition: 0.5s; }  a.close-overlay {   display: block;   position: absolute;   top: 0;   right: 0;   z-index: 100;   width: 45px;   height: 45px;   font-size: 20px;   font-weight: 700;   color: #fff;   line-height: 45px;   text-align: center;   background-color: #000;   cursor: pointer; } a.close-overlay.hidden {   display: none; }  a.expand {   display: block;   position: absolute;   z-index: 100;   width: 60px;   height: 60px;   border: solid 5px #fff;   text-align: center;   color: #fff;   line-height: 50px;   font-weight: 700;   font-size: 30px;   -webkit-border-radius: 30px;   -moz-border-radius: 30px;   -ms-border-radius: 30px;   -o-border-radius: 30px;   border-radius: 30px; }   #effect-2 .overlay {   top: 0;   left: 0;   right: 0;   width: 100%;   height: 0; } #effect-2 .overlay a.expand {   left: 0;   right: 0;   top: 50%;   margin: -30px auto 0 auto; } #effect-2 .img.hover .overlay {   height: 100%; } 

can tell me how so

you should use unique ids in html. recommend use classes instead of id. can in css

div[id^="tocolor-"] {     /* css rules */ } div[id^="tocolor-"] .overlay {     /* css rules */ } 

and in html can add id using database table id this

<div id="effect-<?php echo $id; ?>" class="effects clearfix"> 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -