Display Dynamic Table in tabs with buttons

Hi i am just wondering if any one can help me
with adding each category with their own table in Tabs

Theres no Guide that has worked to do this



<?php
require_once("config.php");
?>
<ul class="nav nav-tabs mb-3" id="nav-tab" role="tablist">
  <li class="nav-item">
    <a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-selected="true"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzXaAV09DJXQ2QEmEH_dBhnlwB1jtqHW7KIhc1Way7-6Kgvzo3QyDU8YjPtnNrfW8J9LE&usqp=CAU" height="30" width="36"> all links</a>
  </li>
    <?php
     $sql = "SELECT * FROM list WHERE approved='1' GROUP BY coin ASC";
     $result = mysqli_query($link, $sql);
     if( $result )    
     while($ew1 = mysqli_fetch_assoc($result)) {
   ?>
  <li class="nav-item">
    <a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-profile" role="tab" aria-controls="pills-profile" aria-selected="false">
        <img src="<?php echo htmlentities($ew1['image']);?>"height="30" width="36" >
    <?php echo htmlentities($ew1['coin']);?></a>
    <?php } ?>
  </li>
</ul>

<div class="tab-content" id="pills-tabContent">
  <div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab"> SHOW all links here


<div class="table-responsive">
          <table class="table table-striped table-bordere" id="list" width="100%" cellspacing="0">
                <thead> 
                <tr>
                <th><center>coin</center></th>
                <th><center>name</center></th>
                <th><center>owner</center></th>
                <th><center>owner</center></th>
                  </tr>
                </thead>          
<?php
$result = mysqli_query($link, "SELECT * FROM list WHERE approved='1' ORDER BY coin DESC"); // using mysqli_query instead
?>


<?php
while ($contact = mysqli_fetch_assoc($result)) {
            // Print out the contents of each row into a table
            echo "<tr>"; 
            echo "<td><center>".$contact['coin']."</center></td>";
            echo "<td><center>".$contact['wallet']."</center></td>";     
           echo "<td><center>".$contact['owner']."</center></td></th>";  
                      echo "<td><center>".$contact['owner']."</center></td></th>";     
echo "</tr>";        
                 }
                  echo "</table>";
                  echo "</div>";
 ;?> 
  </div>
<?php
$result = mysqli_query($link, "SELECT * FROM list WHERE  approved='1' ORDER BY coin "); // using mysqli_query instead
?>
  <div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
 </br> 
  <?php
while ($contact3 = mysqli_fetch_assoc($result)) {
            // Print out the contents of each row into a table
            echo "<tr>"; 
            echo "<td><center>".$contact3['coin']."</center></td>";
            echo "<td><center>".$contact3['wallet']."</center></td>";     
           echo "<td><center>".$contact3['owner']."</center></td></th>";  
                      echo "<td><center>".$contact3['owner']."</center></td></th>";     
echo "</tr>";        
                 }
                  echo "</table>";
                  echo "</div>";

 ;?> 
   </div>
</div>




Rather than posting a bunch of code without any statement of what’s correct or incorrect about what it does, you would be better off posting an example of your data and what end result you are trying to achieve from that data.

Also, I recommend moving all of the database specific code to be above the start of the html document, fetching all the data from any queries into appropriately named php variables, then simply testing/looping over those php variables at the correct locations in the html document.

I also note that your second table has no opening tag.

Separating all of this stuff out of the HTML will make your code much more readable and help prevent HTML errors like this.

Hi the end Goal is i want to make something like webslesson
Like showing here Create Dynamic Tabs by using Bootstrap in PHP Mysql
but with images

i got their guide working but it only display 1 row now

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.