duankuaizhe8257 2019-07-04 21:27
浏览 77

我正在尝试用PHP做一个文章生成器,我无法删除它们

!http://image.noelshack.com/fichiers/2019/27/4/1562273901-image.png

I'm currently trying to do an articles generator with PHP and it kinda works BUT I can't delete ("SUPPRIMER" links) my articles and I dont know why, can you check my code

I already tried the code before in another folder and it works fine but here no, why ? Not file location problem since i'm doing everything in the same file (index.php)

Maybe my block is not in the good place of the code ? idk

<?php $articles = $bdd->query('SELECT * FROM articles ORDER BY date_time_publication DESC'); ?>

    <ul>
          <?php 

          while($a = $articles->fetch()) 
          {
          echo '<li><a href="articles.php?id=' . $a['id']. '">' . $a['titre'] . '</a> | <a href="index.php?edit=' . $a['id'] . '">Modifier </a> | <a href= "index.php?suppression=true&id=' . $a['id'] . '">Supprimer</a></li>';
          }

    if(isset($_GET['suppression']) && $_GET['suppression'] == true)
    {

        $suppr_id = htmlspecialchars($_GET['id']);
        $suppr = $bdd->prepare('DELETE FROM articles WHERE id = :id');

        $suppr->bindParam(':id', $suppr_id);
        $suppr->execute();
        header('location:index.php');
        exit();
    }
        ?>
    </ul>

It's just a block from a whole page of code, if you want the complete code here it is https://sharemycode.fr/test

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 2024-五一综合模拟赛
    • ¥15 如何将下列的“无限压缩存储器”设计出来
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口