【发布时间】:2018-05-23 21:11:18
【问题描述】:
这是我接收数据并将数据插入在线数据库的 php 代码。我很确定我这些捏造的代码不会起作用,但有了你的教育和帮助,我会得到。谢谢。插入数据.php
<?php
include 'connect.php';
include 'function.php';
//Create Object for DB_Functions clas
$db = new DB_Functions();
//Get JSON posted by Android Application
$json = $_POST["usersJSON"];
//Remove Slashes
if (get_magic_quotes_gpc()){
$json = stripslashes($json);
}
//Decode JSON into an Array
$data = json_decode($json);
//Util arrays to create response JSON
$a=array();
$b=array();
//Loop through an Array and insert data read from JSON into MySQL DB
for($i=0; $i<count($data) ; $i++)
{
//Store User into MySQL DB
$res = $db->storedata($data[$i]->callid,$data[$i]->pid,$data[$i]->pname,$data[$i]->medstay_amt,$data[$i]->med_amt,$data[$i]->imv_amt,$data[$i]->othermc_amt,$data[$i]->emtrans_amt,$data[$i]->outpden_am,$data[$i]->otherps_amt,$data[$i]->herb_amt,$data[$i]->medban_amt,$data[$i]->othermp_amt,$data[$i]->assist_amt,$data[$i]->code,$data[$i]->date);
//Based on inserttion, create JSON response
if($res){
$b["id"] = $data[$i]->pid;
$b["status"] = 'yes';
array_push($a,$b);
}else{
$b["id"] = $data[$i]->pid;
$b["status"] = 'no';
array_push($a,$b);
}
}
//Post JSON response back to Android Application
echo json_encode($a);
?>
【问题讨论】:
-
我看到你在使用 jQuery,看看这里:api.jquery.com/jquery.ajax
-
感谢您的更正和快速响应。我会看看然后回来。
-
对不起,我还是个新手。不幸的是,我无法根据页面内容创建自己的代码。请是否可以使用我的代码来帮助我完成它
-
点击
.BTN_Submit_Task或.BTN_Sub后是否要发送请求?你想传递什么数据?AllTasks对象? -
是的,先生。请帮我 。单击按钮后,记录应发送到我的 php Web 应用程序页面。数据库表名是问题。谢谢
标签: javascript php jquery local-storage