/**
 
 $UpDown //移动方向,up或down
 
 $table //表名
 
 $id //当前移动的ID
 
 $id_col //ID字段的名称
 
 $oc_col //排序字段的名称
 
 $where //条件
 
*/
 
function MoveUpDown($UpDown,$table,$id,$id_col='id',$oc_col='OrderColumn',$where='')
 {
   if($UpDown=='up'){$op='<';$desc='desc';}else{$op='>';$desc='';}
   if($where!='') $where="$where and";
   $rs=mysql_query("select $id_col,$oc_col from $table where $where {$oc_col}{$op}=(select $oc_col from $table where $id_col=$id) order by $oc_col $desc limit 2");
   if($row=mysql_fetch_array($rs)){$id1=$row[$id_col];$oc1=$row[$oc_col];}
   if($row=mysql_fetch_array($rs)){$id2=$row[$id_col];$oc2=$row[$oc_col];}
   mysql_free_result($rs);
   if(isset($id1)){
    mysql_query("update $table set $oc_col= ".$oc2." where $id_col=$id1");
   }
   if(isset($id2)){
    mysql_query("update $table set $oc_col= ".$oc1." where $id_col=$id2");
   }
   echo "<script type='text/javascript'>window.location.href='".$_SERVER['PHP_SELF']."';</script>";exit; //移动后刷新页面
 }

最新文章

  1. C#计算代码执行时间
  2. Android中top命令字段含义
  3. nim也玩一行流,nim版的list comprehension
  4. 解析jquery获取父窗口的元素
  5. ubuntu下nginx+php5的部署
  6. Android中的进程与线程
  7. PetaPoco入门(一)
  8. mysql 循环插入日期递增
  9. vIDC v2.0 强大的端口转发神器使用总结-开放内网tfs代码服务
  10. 手机端js事件支持(event)
  11. Android开发-API指南-&lt;uses-sdk&gt;
  12. Quartz.Net使用
  13. Project not selected to build for this solution configuration.
  14. POJ_3111_K_Best_(二分,最大化平均值)
  15. python之加密
  16. hdu 5656 CA Loves GCD(dp)
  17. Mysql用户相关操作
  18. 源码(08) -- java.util.ListIterator&lt;E&gt;
  19. 【zabbix系列】安装与加入host
  20. GPUImage实战问题解决

热门文章

  1. DTCMS添加文章,将tags标签的值赋到SEO关键词上,以及将摘要的值赋到SEO描述
  2. sql server 查看创建视图的sql语句
  3. Jquery get parameter value
  4. Natural Language Processing with Python - Chapter 0
  5. 【多路复用】I/O多路复用
  6. shell 实现word count
  7. Critical Rendering Path
  8. 1054: [HAOI2008]移动玩具 - BZOJ
  9. hdu 4403
  10. uva 825