我正在用angular和php构建一个项目,我有一个客户表,可以检索所有数据。我添加删除按钮删除行,但删除只在HTML页面上,而不是从数据库中删除(当我刷新所有数据返回)。谁能帮忙?我不知道做什么用的代码做为什么我不能从数据库中删除一行?
PHP:
<?php error_reporting(E_ALL); ini_set('display_errors', 1);
$connect=mysqli_connect('localhost', 'root', '', 'hamatkin');
if(isset($_GET['customer_id'])){
$id=$_GET['customer_id'];
$del="DELETE FROM customers WHERE customer_id='".$id."'";
mysqli_query($connect,$del);
echo "$_GET['customer_id']";
}
?>
控制器:
$scope.delete = function(deletingId, index){
var params = $.param({"customer_id":deletingId})
$http({
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
url: "api/deleteCustomer.php?customer_id=?" + deletingId ,
method:"GET",
data:params
}).success(function(data){
$scope.customers.splice(index,1);
console.log(data);
});
行不'和客户id =?''但客户id =' – nospor
@nospor还是您的要求在一些控制台一样的.... – kapi
检查响应例如。 Firebug for Firefox – nospor