Mysql 数据库 - 需要 3 个相等的列

Mysql Database - Need 3 equal columns

我有来自 mysql 数据库的 3 列的结果。列具有正确的信息,但是列数据全部压缩在一起,如您在 http://althedge.xyz/index2.html 中看到的那样 我对 html 知之甚少,并且正在尝试使列在页面上均匀分布。谁能告诉我如何做到这一点?谢谢

代码如下:

<?php

// Database Settings 
define('DB_HOST', 'localhost');
define('DB_PORT', '3306');
define('DB_USER', '*****');
define('DB_PASS', '*****');
define('DB_NAME', '*****');

// Connection to Database
$database = new MySQLi(DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_PORT);

$sql = 'SELECT * '
        . ' FROM posts';

$resultSet = $database->query($sql);


// Begin building some HTML output

$html = '<table border="0">
<tr>
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
</tr>';

while ($row = $resultSet->fetch_assoc())
{
$html .= '<tr>';
$html .= '<td>' . $row['Column1'] . '</td>';
$html .= '<td>' . $row['Column2'] . '</td>';
$html .= '<td>' . $row['Column3'] . '</td>';
$html .= '</tr>';
}

$html .= '</table>';
echo $html;

?>

使用

<table border="0" style="width: 100%;">

使 table 横跨页面的整个宽度。请注意,列的大小仍然不同。

要使所有列的间距相等,您可以使用

<table border="0" style="width: 100%; table-layout: fixed;">