我们假定云服务器为http://180.200.24.1:8080,接口为delete.php,使用腾讯云数据库,内网地址为:172.15.0.2:3306,数据库结构如下:
数据库的名字为testinfo,数据表为datatest
delete.php如下:
$name=$_GET["username"] ;//接收参数
$conn = mysqli_connect("172.15.0.2", "root","*****","testinfo");//连接MYSQL数据库
if(!$conn)
{
die('Could not connect:' .mysqli_error());
}
$sql = "delete from datatest where username='{$name}'";
$result = mysqli_query($conn, $sql);
小程序端:
index.js
wx.request({
url:'http://180.200.24.1:8080/delete.php',
data:{
username:'zhansan',
},
method:'GET'
})