php代码如何更新,如何编写php代码更新web服务

我有一个web服务启动并运行,但我只能从我的数据库读取数据。如何编写php代码更新web服务

任何人都可以帮助/指导我如何将PHP文件编码成能够写入我的数据库?

// Create connection

$con=mysqli_connect("server_address","database_name","user_name","table_name");

// Check connection

if (mysqli_connect_errno())

{

echo "Failed to connect to MySQL: " . mysqli_connect_error();

}

// This SQL statement selects ALL from the table ’table_name’

$sql = "SELECT * FROM table_name/";

// Check if there are results

if ($result = mysqli_query($con, $sql))

{

// If so, then create a results array and a temporary one

// to hold the data

$resultArray = array();

$tempArray = array();

// Loop through each row in the result set

while($row = $result->fetch_object())

{

// Add each row into our results array

$tempArray = $row;

array_push($resultArray, $tempArray);

}

// Finally, encode the array to JSON and output the results

echo json_encode($resultArray);

}

// Close connections

mysqli_close($result);

mysqli_close($con);

?>

+3

http://dev.mysql.com/doc/refman/5.6/en/insert.html –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值