Php 我试图以表格格式显示sql数据库中的信息,我做错了什么?
好的,我可以将数据从数据库显示到页面上,但是我在以表格格式很好地显示数据时遇到了一个问题,因此它位于页眉下,而gos位于页面下方。这就是目前发生的情况: 这是我的页面代码:Php 我试图以表格格式显示sql数据库中的信息,我做错了什么?,php,html,mysql,css,Php,Html,Mysql,Css,好的,我可以将数据从数据库显示到页面上,但是我在以表格格式很好地显示数据时遇到了一个问题,因此它位于页眉下,而gos位于页面下方。这就是目前发生的情况: 这是我的页面代码: <link rel="stylesheet" href="css/productiontable.css"> <?php error_reporting(0); require './db/connect.php'; include './includes/header.php'; ?> <
<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';
请尽可能多地帮助。非常感谢:)有几件事不对: 1.br标签是不需要的。
2.循环应该在tr之外。这样,每一行都会产生一个新行。您的循环控件位于错误的位置。它需要在TR之外。表格单元格不需要浮动,它们不能有边距,只有填充物。最重要的是,您可以将它们垂直对齐到顶部
垂直对齐:顶部代码>@DavidSoussan非常感谢,现在开始工作:)@Caelea非常感谢,现在开始工作:)
@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;
}