gpt4 book ai didi

php - 保存检索到的数据

转载 作者:行者123 更新时间:2023-11-29 23:42:01 24 4
gpt4 key购买 nike

在这个页面上,我通过html组件展示数据。我将从“favoris”表的列表中检索列“profile”保存起来

<?php
require 'Connexion.php';
$c = new Connexion();
$c->query("select * from annonce where id_annonce=:id");
$c->bind(':id', $_GET['id']);
$r = $c->single();
?>
<!DOCTYPE html>
<html>
<head>

<title>Détails d'annonce</title>
</head>
<body>
<div id="Wraper">
<div id="Middle">
<div class="Left">

<div class="Content FCKeditor">
<h1><?php echo($r['profil']); ?></h1>
<div class="Jobdetails">
<form method="post" action="ajout_favoris.php?<?php echo($r['id_annonce']) ?>">
<p class="Date"><span></span> |
<span><a href="#"><?php echo($r['clt']); ?></a></span> |
<span><?php echo($r['contrat']); ?></span>
<span class="imageDroite">
<input type="submit" height="15" width="16" src="favoris-icon.png" value="ajouter aux favoris"/>
</span>
</p>
</form>
<?php echo text_format($r['d_annonce']); ?></br>
</div>

</div> </div>

</div>
</div>
</body>
</html>

当我单击按钮时,数据库中没有保存任何内容。ajout_favoris.php

<?php
require 'Connexion.php';
$c = new Connexion();
$c->query("insert into favoris (titre_fav) select profil from annonce where id_annonce =:id");
$c->bind(':id', $_GET['id_annonce']);
$c->execute();
header("location: javascript:history.go(-1);");
?>

最佳答案

您必须使用 get 并且必须指定一个字符串来传递查询字符串,例如action="ajout_favoris.php?id_annonce = "

    <div class="Content FCKeditor">
<h1><?php echo($r['profil']); ?></h1>
<div class="Jobdetails">

<p class="Date"><span></span> |
<span><a href="#"><?php echo($r['clt']); ?></a></span> |
<span><?php echo($r['contrat']); ?></span>
<span class="imageDroite">
<a href="ajout_favoris.php?id_annonce = <?php echo($r['id_annonce']) ?>">
ajouter aux favoris</a>//changed line
</span>
</p>
<?php echo text_format($r['d_annonce']); ?></br>
</div>

</div> </div>

</div>

关于php - 保存检索到的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26118463/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com