【问题标题】:table class not working after inserting sql database inside插入sql数据库后表类不起作用
【发布时间】:2018-03-02 13:18:19
【问题描述】:

我首先做了表格布局并确保一切正常,在将表格连接到数据库并尝试将记录放入其中后,一切正常,但是课程没有,我现在有没有布局的无聊表格制作。

    <body>
     <h1>Employees</h1>
     <table class="responstable">
    <?php
    require 'connection.php';
    $conn    = Connect();



    $result = mysqli_query($conn,"SELECT * FROM employee");


    echo "<table border='1'>


      <tr>
        <th>Id</th>
        <th>First name</th>
        <th>Last name</th>
        <th>Salary</th>
        <th>Start Date</th>
        <th>Department</th>
      </tr>";


    while($row = mysqli_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['firstname'] . "</td>";
    echo "<td>" . $row['lastname'] . "</td>";
    echo "<td>" . $row['salary'] . "</td>";
    echo "<td>" . $row['startdate'] . "</td>";
    echo "<td>" . $row['department'] . "</td>";
    echo "</tr>";
    }
    echo "</table>";

    mysqli_close($conn);
    ?>



      <script src='http://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js'></script>


    </body>
    </html>

表类是“负责任的”

【问题讨论】:

    标签: php html css sql class


    【解决方案1】:

    table 标记在 2 个地方定义。请尝试删除它。

    echo "<table border='1'>
    

    或者删除h1标签后顶部的table标签,并将class添加到echo中定义的table标签中, 完整代码

    <body>
         <h1>Employees</h1>
        <?php
        require 'connection.php';
        $conn    = Connect();
    
    
    
        $result = mysqli_query($conn,"SELECT * FROM employee");
    
    
        echo "<table border='1' class='responstable'>
    
    
          <tr>
            <th>Id</th>
            <th>First name</th>
            <th>Last name</th>
            <th>Salary</th>
            <th>Start Date</th>
            <th>Department</th>
          </tr>";
    
    
        while($row = mysqli_fetch_array($result))
        {
        echo "<tr>";
        echo "<td>" . $row['id'] . "</td>";
        echo "<td>" . $row['firstname'] . "</td>";
        echo "<td>" . $row['lastname'] . "</td>";
        echo "<td>" . $row['salary'] . "</td>";
        echo "<td>" . $row['startdate'] . "</td>";
        echo "<td>" . $row['department'] . "</td>";
        echo "</tr>";
        }
        echo "</table>";
    
        mysqli_close($conn);
        ?>
    
    
    
          <script src='http://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js'></script>
    
    
        </body>
        </html>
    

    【讨论】:

    • 我真笨!谢谢 !当我可以时将其标记为答案
    猜你喜欢
    • 2016-07-02
    • 1970-01-01
    • 2017-10-07
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多