Carousel bringing a table with database information

Asked

Viewed 382 times

0

is the following I wanted to know if it is possible to put a table inside the Carousel, bringing the data of 5 in 5 lines, when it completes 5 lines the next data would continue in the next page, would function there as a pagination of a table. i tried, but I’m only getting one page on a line. Please help me folks!!!

<?php include'conexao.php'; ?>
<html>
    <head>
         
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script src="js/jquery-3.2.1.min.js" ></script>
        <link type="text/css" rel="stylesheet" href="css/bootstrap.css" >
        <script src="js/bootstrap.js"></script>
        <link rel="stylesheet" type="text/css" href="css/index.css">
        
    </head>
    <body>
    <div align="center">
        <form id="conteudo" >
            <div id="myCarousel" class="carousel slide" data-ride="carousel">
      <!-- Indicators -->
      <ol class="carousel-indicators">
           <?php
                $ctrAtivo = 2 ; 
                $ctrSlide = 1 ;
                $sql = "SELECT * FROM exames ORDER BY id ASC";
                    
                $resultados = mysqli_query($con,$sql);
                
                while($rows = mysqli_fetch_assoc($resultados)){ 
          ?>
                   
                <?php  if($ctrAtivo == 2){ ?>
          
                     <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
          
          <?php                                    
            $ctrAtivo = 1;                                  
          }else{ ?>
          
                    <li data-target="#myCarousel" data-slide-to="<?php echo $ctrSlide ?>"></li>
          <?php
              $ctrSlide++;
          }
            ?>  
        
          <?php
                            
                }
            
            ?>
          
      </ol>
      <div class="carousel-inner" role="listbox">
          <?php
                $ctrAtivo = 2 ; 
            
          
                $sql = "SELECT * FROM exames ORDER BY id ASC";
                    
                $resultados = mysqli_query($con,$sql);
                
                while($rows = mysqli_fetch_assoc($resultados)){ 
          ?>
                   
                <?php  if($ctrAtivo == 2){ ?>
          
                     <div class="item active">
                             <table border="1">
                
                                   <tr>
                                        <td><?php echo"$rows[paciente]"; ?></td>
                                        <td><?php echo"$rows[medico]"; ?></td>
                                        <td><?php echo"$rows[crm]"; ?></td>

                                   </tr>

                               </table>
                    
                      <div class="container">
                        <div class="carousel-caption">
                          
                        </div>
                      </div>
                    </div>
          
          <?php                                    
            $ctrAtivo = 1;                                  
          }else{ ?>
          
                <div class="item ">
                             <table border="1">
                
                                   <tr>
                                        <td><?php echo"$rows[paciente]"; ?></td>
                                        <td><?php echo"$rows[medico]"; ?></td>
                                        <td><?php echo"$rows[crm]"; ?></td>

                                   </tr>

                               </table>
                    
                      <div class="container">
                        <div class="carousel-caption">
                          
                        </div>
                      </div>
                    </div>   
          
          <?php
          }
            ?>  
        
          <?php
                            
                }
            
            ?>
          
      <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
        </div>
          
    </div>
    
     </form>
     
     
</div> 
    
    
    </body>
</html> 

  • tried using mysqli_fetch_all instead of mysqli_fetch_assoc?

  • Yes friend, gave error. but actually I wanted to bring 5 lines per each page of the Carousel. But I am grateful for your suggestion.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.