实现此目的的一种方法是在同一页面上提交。例如 position.php
如果您有 3 条记录,请考虑:
John bla bla(位置 1)
Mary bla bla(位置 2)
George bla bla(位置 3)
一开始你需要这样的链接
    <a href="position.php?position=<?=$position?>&id=<?=$id?>">up</a>
如上所示,$position 是元素的当前位置,id 是表的 id。
当您单击该链接时
    $_GET['position'] and $_GET['id'] 
你有当前记录的位置和id。
因此,您可以执行以下操作
 <?php
         //connect to DB
         if(isset($_GET['position']) && isset($_GET['id'])){
           $line = $_GET['position'];    
          $id = $_GET['id'];
          //if line is not the first one    
         if($line!=1){       
        $query = "select id,position from pages where position<$line order by position   desc limit 0,1";
       $result = mysql_query($query);
       $row = mysql_fetch_array($result);
       $gotoLine = $row['position'];//line to go to
       $idLine = $row['id'];
       //one position up
       $queryUpdate = "update pages set position=$gotoLine where id=$id";
       mysql_query($queryUpdate);
       //one position down
       $queryUpdate2 = "update pages set position=$line where id=$idLine";
       mysql_query($queryUpdate2);
   }     
}
   $queryLinks = "select * from pages order by position";
   $resultLinks = mysql_query($queryLinks);
   while($rowLinks = mysql_fetch_array($resultLinks)){
   $name = $rowLinks['name'];
   $id = $rowLinks['id'];
   $position = $rowLinks['position'];
   echo "$name<a href='position.php?position=$position&id=$id'> up </a><br/>";
}    
?>