dongwo5686 2017-01-01 16:12
浏览 21
已采纳

从db减少/增加顺序删除文章php [关闭]

First of all I wish you a new happy year! So I have 3 articles for example and each of them has an order, like 1,2,3. If I want to delete the last article for example, the order of the other articles still remain the same 1,2. But if I delete the first article the orders of the others should decrease with 1 and if I delete the middle one only the order of the last article should decrease. Now how to do this in php? I refer to delete in database Any idea is appreciated. I don't have any code yet because I wanted to find first a solution, I only give the id of the article, the order and the category from which it belongs:

 if($_POST['actiune'] == 'updateArticle'){
        $id_article = $_GET['id'];
        $ord = $_GET['order'];
        $categ = $_GET['categ'];


    }
  • 写回答

1条回答 默认 最新

  • dougan5772 2017-01-01 16:30
    关注

    You could do an update after each delete. Something like:

    UPDATE [ArticleTable] SET [OrderColumn]=[OrderColumn]-1 WHERE [OrderColumn]>=[ORDERVALUE_FROM_DELETED_ITEM]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?