试图弄清楚如何将新帖子提交到已经使用mysql数据库中的数据条目创建的预先存在的表.我希望它测试请求是否首先来自POST,如果是,则将新行插入数据库并在表中显示新数据.这是我到目前为止所提出的,但在提交时,似乎没有任何事情发生,我的桌子就消失了.任何帮助是极大的赞赏.
这是我到目前为止所拥有的:
$result = mysqli_query($dbconnect, $query);
$num_rows = mysqli_num_rows($result);
}
if ($num_rows > 0) // build a table to show results
{
echo "<table border='1'>";
echo "<tr>";
echo "<th>Post ID </th>"; echo "<th>Author</th>";
echo "<th>Title</th>"; echo "<th>Post</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['pid'] . "</td>";
echo "<td>" . $row['author'] . "</td>";
echo "<td>" . $row['title'] . "</td>";
echo "<td>" . $row['post'] . "</td>";
echo "</tr>";
}
echo "</table>";
} else{
echo "No rows returned."; …Run Code Online (Sandbox Code Playgroud)