【发布时间】:2021-10-21 14:37:09
【问题描述】:
我决定重新尝试学习 PHP,并且我以前创建过这种东西,但我认为已经有一段时间了,所以我决定尝试再做一个。我正在尝试制作数据库表/页面。但是表格中的数据并没有正确对齐。这是它的样子 https://prnt.sc/1qcrdo8 以下是我的代码:
index.php
<?php
main();
function main() {
include('index.html');
require('../Content/dbconnect.php');
$sql="SELECT * FROM Orders";
$result=mysqli_query($conn,$sql);
$count = mysqli_num_rows($result);
if ($count>0) {
while ($row = $result->fetch_row()) {
echo "<table class='content'>";
echo "<tr><td>" . $row[0] . "</td><td>" . $row[1] . "</td><td>" . $row[2] . "</td><td>" . $row[3] . "</td></tr>";
echo "</table>";
}
}
}
还有我的 index.html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="Style/Style.css">
<title>Admin Panel</title>
</head>
<body>
<table>
<div class="content">
<table id="content" class="content">
<tr>
<th>ID</th>
<th>CustomerName</th>
<th>Order ID</th>
<th>Customer Address</th>
<th>Problems Described</th>
<th>Notes for the customer</th>
</tr>
</table>
</body>
</html>
【问题讨论】:
-
可以使用 CSS 设置对齐方式
-
当您说右对齐时,您的意思是您希望文本右对齐吗?还是要正确对齐?如果正确,在这种情况下什么是正确的?此外,这是一个地狱般的地址。
-
@ADyson 是的,我确实尝试过,因此为什么回显的文本在中间,它只是没有与行对齐