鍍金池/ 問(wèn)答/HTML/ 如何寫(xiě)這個(gè)append?

如何寫(xiě)這個(gè)append?

讀取數(shù)據(jù)部分

<?php
include("conn.php");
$result = $conn->query("select * from lyb limit 4");
while($row = $result->fetch_assoc()){
    echo "<tr><td>" . $row['title'] ."<td/>";
    echo "<td>" . $row['content'] ."<td/>";
    echo "<td>" . $row['author'] ."<td/>";
    echo "<td>" . $row['email'] ."<td/>";
    echo "<td>" . $row['ip'] ."<td/></tr>";
};
?>

顯示數(shù)據(jù)部分

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    
<script src="http://127.0.0.1/phpbook/jquery-3.3.1.min.js"></script>
<script>
$(function(){
    $.get("p408.php",function(data){
        $("#disp").append(data);
        });
});
</script>
<h2 align="center">以ajax方式顯示數(shù)據(jù)</h2>
<table border="1" width="100%">
    <tbody>
        <tr id="disp">
            <th>標(biāo)題</th>
            <th>內(nèi)容</th>
            <th>作者</th>
            <th>email</th>
            <th>ip</th>
        </tr>
    </tbody>
</table>
</body>
</html>

上面的寫(xiě)法,數(shù)據(jù)顯示成
圖片描述

table部分修改成這樣的話

<table border="1" width="100%">
    <tbody  id="disp">
        <tr>
            <th>標(biāo)題</th>
            <th>內(nèi)容</th>
            <th>作者</th>
            <th>email</th>
            <th>ip</th>
        </tr>
    </tbody>
</table>

顯示成這樣

圖片描述

如何讓它一行接一行的正確顯示?

回答
編輯回答
若相惜

1.td結(jié)束標(biāo)簽的寫(xiě)法是</td>不是<td/>
2.table部分

<table border="1" width="100%">
    <tbody  id="disp">
        <tr>
            <th>標(biāo)題</th>
            <th>內(nèi)容</th>
            <th>作者</th>
            <th>email</th>
            <th>ip</th>
        </tr>
    </tbody>
</table>


2017年9月3日 03:42
編輯回答
我以為

字符串拼接有問(wèn)題,td結(jié)束標(biāo)簽的寫(xiě)法是</td>不是<td/>

2018年8月13日 17:26