我想在PHP中做一個簡單的CMS。在滑塊管理中,我想更改添加的照片的順序。PHP中的phpmyadmin訂購商品
<a href="slideup.php?order=<?php echo $result['order']; ?>&id=<?php echo $result['id']; ?>" title="Up"><img src="../images/up.png" alt="Up" /></a>
<a href="slidedown.php?order=<?php echo $result['order']; ?>&id=<?php echo $result['id']; ?>" title="Down"><img src="../images/down.png" alt="Down" /></a>
它發送相關的PHP頁面,當前的訂單和幻燈片的ID。
slideup.php
<?php
include('includes/functions.php');
$order=$_REQUEST['order'];
$id=$_REQUEST['id'];
goUp($order, $id);
?>
slidedown.php
<?php
include('includes/functions.php');
$order=$_REQUEST['order'];
$id=$_REQUEST['id'];
goDown($order, $id);
?>
的functions.php
function goUp($order, $id)
{
$db = new DB_CONNECT();
if(!$order == 1)
{
$neworder = $order - 1;
mysql_query("UPDATE `slider` SET `order`='$order' WHERE `order`='$neworder'") or die(mysql_error());
mysql_query("UPDATE `slider` SET `order`='$neworder' WHERE `id`='$id'") or die(mysql_error());
}
header('Location: ../admin/slider.php');
}
function goDown($order, $id)
{
$db = new DB_CONNECT();
$totalslide = 0;
$query = mysql_query("SELECT COUNT(`id`) as count FROM `slider`") or die(mysql_error());
$result = mysql_fetch_array($query);
$totalslide = $result['count'];
if(!$order == $totalslide)
{
$neworder = $order + 1;
mysql_query("UPDATE `slider` SET `order`='$order' WHERE `order`='$neworder'") or die(mysql_error());
mysql_query("UPDATE `slider` SET `order`='$neworder' WHERE `id`='$id'") or die(mysql_error());
}
header('Location: ../admin/slider.php');
}
當我點擊圖標,代碼工作沒有任何問題。但結果是,沒有任何反應。有關於我的代碼或邏輯錯誤的問題嗎?
謝謝。
echo mysql_error();
讓我們知道它說:
OT:你當前的代碼容易受到sql注入 – Stefan