Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我试图以表格格式显示sql数据库中的信息,我做错了什么?_Php_Html_Mysql_Css - Fatal编程技术网

Php 我试图以表格格式显示sql数据库中的信息,我做错了什么?

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

好的,我可以将数据从数据库显示到页面上,但是我在以表格格式很好地显示数据时遇到了一个问题,因此它位于页眉下,而gos位于页面下方。这就是目前发生的情况:

这是我的页面代码:

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