2017-02-26 4 views
0

私は3つのカラムの結果をmysqlデータベースから取得しています。列は正確な情報を持っていますが、列データはすべてhttp://althedge.xyz/index2.htmlのようにまとめられています。私はhtmlの知識がほとんどなく、列をページ全体に均一に広げようとしています。誰も私にこれを達成する方法を示すことができますか?MySQLデータベース - 3つの等価カラムが必要

<?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; 

?> 
+2

を使用することができます間隔。 –

答えて

0

使用

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

表はページの全幅にまたがるようにする:ありがとう

ここでは、コードです。列のサイズは変わりません。すべての列を持っている

が均等に同様にあなたは私が投稿1~2時間前にこれに非常によく似た質問を見たことを誓うことができ

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

ありがとう! – vinman64

関連する問題