时间:2021-07-01 10:21:17 帮助过:6人阅读
实现新闻的上移下移功能
header("Content-type:text/html;charset=gb2312");
include("mysql.class.php");
$conn=new mysql("localhost","root","root","test"," ","gbk");
if(!emptyempty($_GET["weight"])){
if($_GET["move"]=="up"){
//获取上一条新闻信息
$query=$conn->query("select * from `article` where `weight` > '$_GET[weight]' order by `weight` asc limit 1");
if($conn->db_num_rows(query)>0){
$rows=$conn->fetch_array($query);
$conn->query("update `article` set `weight`='$rows[weight]' where `weight`='$_GET[weight]'");
$conn->query("update `article` set `weight`='$_GET[weight]' where `ID`='$rows[ID]'");
}else{
echo "";
}
}else if($_GET["move"]=="down"){
//获取下一条新闻信息
$query=$conn->query("select * from `article` where `weight` < '$_GET[weight]' order by `weight` desc limit 1");
if($conn->db_num_rows(query)>0){
$rows=$conn->fetch_array($query);
$conn->query("update `article` set `weight`='$rows[weight]' where `weight`='$_GET[weight]'");
$conn->query("update `article` set `weight`='$_GET[weight]' where `ID`='$rows[ID]'");
}else{
echo "";
}
}
}
?>