I have the results of 3 columns coming from a mysql database. The columns have the correct information, however the column data is all crunched together as you can see at http://althedge.xyz/index2.html I have little knowledge of html and am trying to get the columns to spread out evenly across the page. Can anyone show me how to accomplish this? Thanks
Here is the code:
<?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;
?>
Use
<table border="0" style="width: 100%;">
to make the table span the full width of the page. Note that the columns will still have different sizes.
To have all columns equally as well spaced you can use
<table border="0" style="width: 100%; table-layout: fixed;">
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments