格式化表MYSQL查询

时间:2011-12-15 01:28:42

标签: php mysql html-table format

我有以下代码在网页上格式化表格,如下所示:

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 个答案:

答案 0 :(得分: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>