2014-09-30 60 views
0

在此頁面上,我通過html組件顯示數據。我會保存列「PROFIL」從列表retrived表「favoris」保存數據回收

<?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);"); 
?> 
+0

我認爲你應該使用'$ _POST'而不是'$ _GET' 並在'ajout_favoris.php'中加入'print_r'' $ _POST'並檢查。 也發佈錯誤日誌,如果有的話 – 2014-09-30 10:39:47

回答

0

你必須使用得到,並有指定的字符串傳遞一個查詢字符串像 行動= 「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> 

+0

它不起作用 – 2014-09-30 13:32:10

+0

其他明智的,你必須直接刪除你的表格標籤使用錨標籤。我正在編輯.. – 2014-09-30 13:36:09

+0

我做到了,但它沒有提供任何東西 – 2014-09-30 13:42:22