溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

php中一個用箭頭實現的上下排序的函數

發(fā)布時間:2020-04-10 07:43:56 來源:網絡 閱讀:1421 作者:liufeng0922 欄目:web開發(fā)

個非常好用上下排序箭頭,大家可以看下了,一定讓你眼前一亮了。。。

此函數有五個參數,分別是當前排序的ID值,位置,箭頭方向,分頁數,參數。

function uporder($PID,$Place,$Direction,$Page,$Param)
{
  global $pl;
  $objResponse = new xajaxResponse();  

  if(!$PID)
  {
    $objResponse->addAlert("對不起,參數錯誤!");
    return $objresponse->getXML();
  }

  if($Direction=="up")
    {$sql = "select * from jj_properties where Place<$Place order by Place desc limit 1";}
  else
    {$sql = "select * from jj_properties where Place>$Place order by Place asc limit 1";}
    
  $result = $pl->query($sql);
  if($rs=$pl->fetch_array($result))
  {
    $Place1 = $rs["Place"];
    $PID1 = $rs["ID"];
        
    $query = "update jj_properties set Place='{$Place}' where id=$PID1"; //與排序的記錄交換位置
    $result1 = $pl->query($query);
    
    $query1 = "update jj_properties set Place='{$Place1}' where id=$PID";
    $result = $pl->query($query1);
  }  
     
  $objResponse->script("xajax_ShetuList('','{$Page}','{$Param}')");
  return $objResponse->getXML();
}

本文出自網站家園,專為網頁制作人員提供技術問答的網站。

網址:www.52webhome.com

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI