doulian8554 2015-03-13 17:19
浏览 7

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

Ok I can display data on to the page from the database but I am having a problem displaying it nicely in a table format so its under headers and gos down the page. This is what has happened at the moment: Problem!

Here is my page code:

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

Here is the css for the table:

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

Please help as much as possible many thanks :)

  • 写回答

1条回答 默认 最新

  • dr2898 2015-03-13 17:29
    关注

    There are a couple of things wrong: 1. The br tag is not needed. 2. The loop should be outside of the tr. This way a new row will be made for every row.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大