Php Mysql调用是否在其他html元素之后呈现?

时间:2016-04-17 23:17:23

标签: php html css mysqli html-table

我正在完成一个大学项目并正确处理我的html渲染问题,因为它代表下面的代码

div
render title
render table
/div

div
render footer
/div

目前正在

div
render title
div
render footer
/div
render footer
/div

有人可以指出错误的位置吗?

<body>

<div class="content main">
<h2>Status Posting System</h2>
<?php

    require_once ("settings.php"); 

    $search = $_GET["search"];

    $conn = @mysqli_connect($host, $user, $pswd)
    or die('Failed to connect to server');

    @mysqli_select_db($conn, $dbnm)
    or die('Database unavailable');

    $query = "SELECT * FROM status WHERE status like '%" . $search . "%'";
    $results = mysqli_query($conn, $query);

    echo "<table width='100%' border ='1'>";
    echo "<tr><th>Status Code</th><th>Status</th><th>Share</th><th>Permission</th>
    <th>Date</th></tr>";

    while($row = mysqli_fetch_assoc($results)) {
    echo "<tr><td> {$row['code']}</td>";
    echo "<td> {$row['status']}</td>";
    echo "<td> {$row['share']}</td>";
    echo "<td> {$row['permission']}</td>";
    echo "<td> {$row['date']}</td>";
    echo "</tr>";
    }

    mysqli_free_result($results);
    mysqli_close($conn);
?>
</div>

<div class="padding-footer"><a class="footer" href="index.php">Return Home</a></div>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

你错过了

</table>
过了一会儿。不知道这是否能解决你的问题。