php简单的mysql查询,php实现的mysql的简单查询删除

5268f80b9b1e01f982625ef6fac83ca1.png

//header(‘Content-Type:text/json;charset=utf-8‘);

$con=mysqli_connect("数据库地址:端口","用户名","密码","数据库名");if (!$con)

{die("连接错误: " . mysqli_connect_error());

}else{echo "成功";

}$action = $_GET[‘action‘];switch ($action) {case ‘del_row‘:del_row();//删除

break;case ‘edit_row‘:edit_row();//查询

break;}functiondel_row(){global $con;$dataid = $_POST[‘dataid‘];$sql = "delete from `order` where `id`=‘".$dataid."‘";if (mysqli_query($con,$sql)) {echo ‘ok‘;

}else{echo ‘删除失败‘;

}

}functionedit_row(){global $con;$sql = "SELECT id, name, mobile FROM `user_address`";//sql查询语句

$result = $con->query($sql);//获得查询结果

if ($result->num_rows > 0) {//输出每行数据

while($row = $result->fetch_assoc()) {$results[] = $row;

}

}else{echo "0 results";

}echo json_encode($results);

}?>

前端代码

$.ajax({

type:"GET",

url:"./data.php?action=edit_row",

data:‘‘,

dataType:"json",

success:function(data){var len =data.length,

str= ‘‘, item;if(len>0) {for (var i = 0; i < len; i++) {

item=data[i];

str+= ‘

‘ +

‘ + item.id + ‘‘ +

‘ + item.name + ‘‘ +

‘ + item.mobile + ‘‘ +

‘ + item.city + ‘‘ +

‘ + item.country + ‘‘ +

‘ + item.detail + ‘‘ +

‘ + ‘ ‘+‘删除‘+‘‘ + ‘‘ +

‘;

}

$(‘#order-table1‘).append(str);

}

}

});

php实现的mysql的简单查询删除

标签:address   nec   app   blog   apache   for   log   type   echo

1428d0e076c3959ab11d28a39bc84fab.png

5268f80b9b1e01f982625ef6fac83ca1.png

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:http://www.cnblogs.com/lqzweb/p/7101743.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值