这是记录数据并发布数据的php代码(post.php):
$titus=$_POST['titus'];
$des=$_POST['des'];
$link=$_POST['link'];
$sql=mysqli_query($conexao,"INSERT INTO titus(titus, des, link)VALUES ('$titus', '$des', '$link')");
$consulta = mysqli_query($conexao, "SELECT * from titus
where idpod = (select max(idpod) from titus)");
while($postagem = mysqli_fetch_object($consulta)){
echo $postagem = $_POST['titus'] .'<br>';
echo $postagem = $_POST['des'] .'<br>';
echo $postagem = $_POST['link'] .'<br>';这是触发post.php的按钮
<form action="postar.php" method="POST">
<button type="submit" class="pubi">Publish</button>
</form>我需要的是,一旦我点击按钮,出版物将永久取代它的位置,以便当有下一个出版物时,它成为一个列表。
发布于 2020-11-05 03:42:20
您需要在echo语句中使用存储在$postagem中的数据。目前,您正在将POST值分配给$postagem,而不是使用$postagem对象中的成员。See the PHP manual on mysqli_fetch_object for more info on this。
您的代码应该如下所示:
while($postagem = mysqli_fetch_object($consulta)){
echo $postagem->titus .'<br>';
echo $postagem->des .'<br>';
echo $postagem->link .'<br>';此外,您当前的代码将在每次运行时尝试插入数据,即使所需字段在$_POST数组中不存在。
https://stackoverflow.com/questions/64686520
复制相似问题