如何将结果输入到html表中?我似乎无法完成此操作。.下面的结果仅给我表的第一行。其余结果显示在HTML之外。我该怎么办?谢谢
<?php
echo "<table style='width:960px;background-color:silver;text-align:center;'>
<tr>
<th>Customer ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Registration Date</th>
</tr>";
require_once("PDOconn.php");
// DISPLAY THE ENTRY IN A FORM
//Define query
try{
$dsn = "mysql:host=$servername;dbname=$dbname";
$conn = new PDO($dsn,$username,$password);
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$stmt = $conn->query('SELECT * FROM `Demo_Guests` ORDER BY reg_date ASC');
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
echo "<tr><td>
<a href=\"click_link.php?id={$row['id']}\"> id # " . $row['id'] . "</a><br></td>";
<td>{$row['firstname']} </td>
<td>{$row['lastname']}</td>
<td><a href=\"send_email.php?id={$row['email']}\">" . $row['email'] . "</a>
</td>
<td> {$row['reg_date']}</td></tr>";
echo "</table><br>";*/
}
}
catch(PDOException $e){
echo $e->getMessage();
}
?>