Мне нужно отобразить строки в таблице, используя переменные php и цикл while, и я не могу понять, что я делаю неправильно.Я пробовал все виды различных комбинаций одинарных и двойных кавычек, но я все еще не могу использовать правильный синтаксис, необходимый для вывода этих строк в таблицу без каких-либо ошибок.Я использую Dreamweaver 2019 для кодирования.Я использовал Netbeans 8.2, но все еще не могу определить правильный синтаксис для этого кода.
Вот также то, что я нашел в stackoverflow, но я все еще не могу найти именно то, что мне нужно.И я не могу найти точно, как использовать правильный синтаксис с помощью Google, либо в этом контексте:
php - для цикла внутри цикла while, правильный синтаксис?
Встроенные стили в PHP
https://stackoverflow.com/search?q=use+inline+styling+with+php+html+table
HTML-таблицы и встроенные стили
HTML-таблица со встроенным PHP
<?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>