2011-12-15 101 views
0

我有以下的代碼格式在這樣一個網頁的表格:格式化表格MySQL查詢

http://thepoolscene.com/rooms-new/

echo "<table border='1'> 
<tr> 
<th>Room Name</th> 
<th>Address</th> 
<th>Phone</th> 
<th>Map</th> 
</tr>"; 

while($row = mysql_fetch_array($result)) 
    { 
    echo "<tr>"; 
    echo "<td font color=red>" . $row['NameofLocation'] . "</td>"; 
    echo "<td>" . $row['Address'] . ", " . $row['City'] . " " . $row['Province'] . "</td>"; 
    echo "<td>" . $row['Phone'] . "</td>"; 
    echo "<td>" . "<a href='http://maps.google.com/maps?q=" . $row['Address'] . "+" . $row['City'] . "+" . $row['Province'] . "&hl=en'target=「_blank」 >Map</a></font></td></tr>" . "</td>"; 
    echo "</tr>"; 
    } 
echo "</table>"; 

我想用一些色彩和空間的出列格式化表更平均一點。有沒有辦法讓每列的寬度自動化?具體來說,電話號碼和地圖字段將保持不變。

+1

你可以使用CSS這個 – 2011-12-15 01:32:16

回答

1

也許這將幫助你

<th style='width:50%; color:red;'>Room Name</th> 
<th style='width:50%; color:red;'>Address</th> 
<th style='width:80px; color:red;'>Phone</th> 
<th style='width:20px; color:red;'>Map</th> 
+0

謝謝,完美的作品。 – DoubleA 2011-12-15 02:08:49