我有一个 javascript for 循环,将数组发送到 ajax 页面以更新 mysql 数据库。
我将结果回显到原始页面,它作为成功回显但是当我检查数据库时没有任何改变
我发送数组的 javascript for 循环
for(var m=0; m<array.length; m++){
$.post("update_page_positions.php",{page_ref:array[m][0], ref:array[m][12], menu_pos:array[m][1], sub_menu_pos:array[m][2], top_menu:array[m][3], pagelink:array[m][4], indexpage:array[m][5], hidden:array[m][6], page_title:array[m][7], page_desc:array[m][8], page_keywords:array[m][9], page_name:array[m][10], deletedpage:array[m][11]},
function(data,status){
alert("data="+data+" status="+status);
});
这是更新数据库的php ajax页面
<?
include("connect.php");
$ref = $_POST['ref'];
$page_ref = $_POST['page_ref'];
$menu_pos = $_POST['menu_pos'];
$sub_menu_pos = $_POST['sub_menu_pos'];
$top_menu = $_POST['top_menu'];
$indexpage = $_POST['indexpage'];
$page_name = $_POST['page_name'];
$page_title = $_POST['page_title'];
$page_desc = $_POST['page_desc'];
$page_keywords = $_POST['page_keywords'];
$hidden = $_POST['hidden'];
$pagelink = $_POST['pagelink'];
$deletedpage = $_POST['deletedpage'];
$query = mysql_query("SELECT * FROM pages WHERE ref='$ref' AND page_ref='$page_ref'");
if(mysql_num_rows($query)==0){
mysql_query("INSERT INTO pages(page_ref, ref, page_name, menu_pos, sub_menu_pos, top_menu, link, indexpage) VALUES('$page_ref','$ref','$page_name','$menu_pos','$sub_menu_pos','$top_menu','$pagelink','$indexpage')");
}
if($deletedpage=="1"){
mysql_query("DELETE FROM pages WHERE ref='$ref' AND page_ref='$page_ref'");
mysql_query("DELETE FROM site_content WHERE ref='$ref' AND page_ref='$page_ref'");
}
else{
if(mysql_query("UPDATE pages SET menu_pos='$menu_pos', sub_menu_pos='$sub_menu_pos', top_menu='$top_menu', indexpage='$indexpage', page_name='$page_name', page_title='$page_title', desc1='$page_desc', keywords_list='$page_keywords', hidden='$hidden', link='$pagelink' WHERE ref='$ref' AND page_ref='$page_ref'")){
echo "updated!";
} else{
echo "error";
}
}
?>
INSERT 和 DELETE 函数很好,但 UPDATE 返回成功语句但不更新数据库。
任何人都可以看到问题是什么?