我想在我以表格的形式显示数据库中的所有数据。我在这里使用while循环。第一行看起来不错,但随后的行不显示一个类似的表格。
require_once"../connect.php";
$sql = "SELECT * FROM history WHERE LOWER(trackingNo)=LOWER('$track') ORDER BY dates DESC";
$result = $con -> query($sql);
if ($result -> num_rows > 0) {
// output data of each row
echo "
< tr >
DATE < /th> TIMEclass='trcol' > LOCATION < /th>
STATUSclass='trcol' > REMARKS < /th>";
while ($row = $result -> fetch_assoc()) {
$dates = $row['dates']; enter code here
$tim = $row['tim'];
$status = $row['status'];
$remarks = $row['remarks'];
$location = $row['location'];
echo"
".$dates." ".$tim."< td > ".$location." < /td>
".$status."".$remarks." < /td>";}
}
else {
echo "0 results";
}
$con -> close();
?>
这是它目前的样子