ios 端使用的是 afnetworking 框架 php 服务器的代码如下
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("emp", $con);
mysql_set_charset('utf8',$con);
$c = file_get_contents("php://input");
$de_json = json_decode($c);
$aa=array();
$sql= mysql_query("SELECT * FROM tianqi WHERE location='$de_json->location'");
while($row=mysql_fetch_object($sql))
$aa = $row;
echo json_encode($aa);
exit;
mysql_close();
还有就是 ios 客户端可以收到用 jsp 编写的服务器发送的 json 。
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("emp", $con);
mysql_set_charset('utf8',$con);
$c = file_get_contents("php://input");
$de_json = json_decode($c);
$aa=array();
$sql= mysql_query("SELECT * FROM tianqi WHERE location='$de_json->location'");
while($row=mysql_fetch_object($sql))
$aa = $row;
echo json_encode($aa);
exit;
mysql_close();
还有就是 ios 客户端可以收到用 jsp 编写的服务器发送的 json 。