【发布时间】:2015-03-14 01:34:47
【问题描述】:
好的,我可以将数据库中的数据显示到页面上,但是我在以表格格式很好地显示它时遇到了问题,因此它位于标题下方并位于页面下方。这是目前发生的事情:
这是我的页面代码:
<link rel="stylesheet" href="css/productiontable.css">
<?php
error_reporting(0);
require './db/connect.php';
include './includes/header.php';
?>
<h2>Productions</h2>
<div class="productiontable">
<table>
<tr>
<th>Production Name</th>
<th>Production Description</th>
<th>Production Type</th>
</tr>
<tr>
<td class="productname">
<?php
if($result = $connection->query("SELECT * FROM Production")){
if($count = $result->num_rows){
while($row = $result->fetch_object()){
echo $row->ProductionName;
?>
</td>
<td class="productinfo">
<?php
echo $row->ProductionInformation;
?>
</td>
<td class="producttype">
<?php
echo $row->ProductionType;
}
?>
</td><bR>
</tr>
</table>
<?php
$result->free();
}
}
mysqli_close($connection);
include './includes/footer.php';
这是表格的css:
@import url(http://fonts.googleapis.com/css?family=Dosis);
h2{
text-align: left;
color: white;
font-family: 'Dosis';
margin: 10px;
font-size: 32px;
}
h3{
font-size: 18px;
color: white;
margin: 20px;
}
.productiontable{
width: 900px;
border: 1px black solid;
margin: 10px;
}
.productname{
width: 200px;
float: left;
font-weight: bold;
margin-left: 10px;
}
.productinfo{
width: 500px;
float: left;
margin-left: 10px;
}
.producttype{
width: 200px;
float: left;
font-style: oblique;
margin-left: 10px;
}
请尽可能多的帮助非常感谢:)
【问题讨论】:
-
你的循环控制放错了地方。它需要在 TR 之外。
-
表格单元格不需要浮动,它们不能有边距,只有填充。最重要的是,您可以将它们垂直对齐到顶部
vertical-align: top; -
@DavidSoussan 非常感谢你现在开始工作了 :)
-
@Caelea 非常感谢你让它工作:)