I need to display rows within a table using php variables and a while loop and I can't figure out what I am doing wrong. I have tried all kinds of different combinations of single quotes and double quotes, but I still can't use the correct syntax needed to make these rows get outputted within the table without generating any errors. I am using Dreamweaver 2019 to code it with. I used Netbeans 8.2 but I still can't figure out the correct syntax for this code.
Here's also what I found on stackoverflow so far but I am still not finding exactly what I need. And I can't find exactly how to use the correct syntax using google either within this context:
php - for loop inside a while loop, correct syntax?
https://stackoverflow.com/search?q=use+inline+styling+with+php+html+table
<?php
include 'connection.php'; // includes the connection.php file to connect
to the database
// query to database and prepares and executes
$query = "SELECT id, first_name, last_name FROM customers ORDER BY
last_name asc";
$stmt = $db->prepare($query);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($id, $first_name, $last_name);
// count the number of customers
$total_customers = $stmt->num_rows;
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Granger Customers</title>
<link href="assets/bootstrap.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--start container to center design in browser-->
<div class="container">
<div class="row" style="margin-bottom:30px">
<div class="col-xs-12">
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="customers.php">Customers</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">Search</a>
</li>
<li class="nav-item">
<a class="nav-link" href="">Add New</a>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<table class="table table-bordered table-striped table-hover">
<p><strong>There are a total of <?PHP echo $total_customers; ?>
customers.</strong></p> <!-- output total number of customers -->
<thead>
<tr class="success">
<th class="text-center">#</th>
<th>Customer ID</th>
<th>Last Name</th>
<th>First name</th>
<th class="text-center">Details</th>
</tr>
</thead>
<tbody>
<tr>
<?php
while($result = $stmt->fetch()) {
echo '<th class="text-center">'#'</th>'
echo <th>"$result"</th>
echo <th>"$result"</th>
echo <th>"$result"</th>
echo <th class="text-center">"Details"</th>
}
?>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!--end container to center design in browser-->
</body>
</html>