点击按钮的排序列

时间:2017-04-11 05:32:05

标签: php jquery mysql ajax

我有一张桌子作为城市,存储进入城市的信息。在城市表中,我有一个列名为city_order,它存储要显示的城市的顺序(1,2,3 ......等)。列出订单时,我在表格中上下箭头。当用户点击任何城市的向上箭头时,我将改变该城市及其上方城市的顺序。我点击箭头调用ajax函数并获取点击城市的顺序。如果单击向上箭头,那么我将前一个城市的顺序变为当前顺序,反之亦然。如果单击向下箭头,我将下一个城市的顺序变为当前顺序,反之亦然。这件事没有按预期工作。请在下面找到ajax代码。

$cityid = $_REQUEST["cityid"];
$cityorder = $_REQUEST["cityorder"];
$type = $_REQUEST["type"];
if(isset($type) && $type == "up"){
    $newcityorder = $_REQUEST["cityorder"] - 1;
}else{
    $newcityorder = $_REQUEST["cityorder"] + 1;
}
$productid = $_SESSION["productid"];
$dclass1->query("update tbl_city set city_order = '$cityorder' where city_order = '$newcityorder' AND item_id = '$productid'");
$dclass1->query("update tbl_city set city_order = '$newcityorder' where cityid = '$cityid'");

0 个答案:

没有答案