PHP利用数据库生成API

来源:互联网 发布:笑郭网络验证4.6 编辑:程序博客网 时间:2024/06/01 09:08

第一步:首先利用HBuilder建立一个PHP项目:

新建一个php文件,与数据库建立连接:

<?php
   $con=mysql_connect("localhost","root","") or die(mysql_error);
     mysql_select_db("test");//test为表名
?>

再次新建一个php文件,生成API

<?php
$randnumber=$_GET['randnumber'];//参数
$username=$_GET['username'];
require 'mysql_connect.php';
mysql_query("update test set username = '$username' where (randnumber) = ('$randnumber')");
?>

生成结果:

http://127.0.0.1:8080/php/save.php?randnumber=21583424&username=dongge


原创粉丝点击