我不太清楚对JSON、PHP和MySQL的理解。
在我的计划中,我将创建一个web服务器,android application.The数据库服务器是MySQL。据我所知,PHP可以发送数据并将其编码到JSON数组中,我如何在Android应用程序中使用这个JSON数组?
发布于 2010-12-16 00:56:27
你的问题很难理解。
您似乎在问如何使用PHP发送JSON数据。
使用PHP和json_decode函数在json_encode和PHP数组之间进行转换。
要发送JSON字符串,首先使用json_encode()将数组转换为JSON,然后print结果字符串并退出程序。
<?php
$my_array = array('this'=>'is', 'just'=>'an', 'example'=>'array');
$json_string = json_encode($my_array);
print $json_string;
die;
?>希望这能有所帮助。
发布于 2011-02-19 13:57:57
以下是PHP代码...
<?php
mysql_connect("host","username","password");
mysql_select_db("Deal");
$sql=mysql_query("select * from CITY where CITY_NAME like 'A%'");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
print(json_encode($output));
mysql_close();
?>这里有一篇很好的文章link。我希望你喜欢它,如果你有任何问题,你可以问,我会尽快解决它。
https://stackoverflow.com/questions/4452131
复制相似问题