how-to-show-data-form-database-in-html-table
How to show data from the database in an HTML table

HTML Code

<div class="container" style="padding-top: 100px;">
  <div class="row">
  <?php while($row=mysqli_fetch_array($result)){ ?>
  <div class="col-sm-12">
    <div class="thumbnail">
      <div style="text-align: center;" class="caption">
       
        <div id="content">
            <div class="table-responsive">
                         <h1 style="text-align: center;">Full Details</h1>
                          <table class="table">
                          <tr>
                          <th style="text-align: center;">Name</th>
                          <th style="text-align: center;">Price</th>
                          <th style="text-align: center;">Quantity</th>
                          <th style="text-align: center;">Quality</th>
                          <th style="text-align: center;">Description</th>
                          <th style="text-align: center;">Category</th>
                          </tr>
<?php    
//showing content 
echo("<div id='img_div'>");
echo("<tr>");
    echo("<td>".$row['name']."</td>");
echo("<td>".$row['price']."</td>");
echo("<td>".$row['quantity']."</td>");
echo("<td>".$row['description']."</td>");
echo("<td>".$row['text']."</td>");
echo("<td>".$row['category']."</td>");
echo("</tr>");
echo("</div>");
?>
</table>
   </div>
</div>
</div>
       
      </div>
    </div>
  <?php } ?>
  </div><!---row---->
  </div><!---container--->

PHP Code

<?php 
include("connect.php");//connection file code in Lecture 4

$query="SELECT * FROM product ";
$result=mysqli_query($connect,$query);
if(!$result)
{
die("Query failed".mysqli_error($connect));
}
?>
Explanation in Lecture 6

Previous Lecture                                                                                                                  Next Lecture