I am not sure about understanding about JSON, PHP, and MySQL.
In my plan, I will create a web server and android application.The database server is MySQL. In my understanding, PHP can send data and encode it into a JSON arra开发者_开发技巧y, how can I use this JSON array in my Android application?
following is PHP code...
<?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();
?>
here is a nice article link. i hope you like it, and if you have any question, you can ask, i will try to solve it as soon as possible.
Your question is difficult to understand.
It seems like you're asking how to send JSON data using PHP.
Use the PHP json_encode
and json_decode
functions to convert between JSON and PHP arrays.
To send a JSON string, first convert the array to JSON using json_encode()
, then print
the resulting string and exit the program.
<?php
$my_array = array('this'=>'is', 'just'=>'an', 'example'=>'array');
$json_string = json_encode($my_array);
print $json_string;
die;
?>
Hope that helps.
精彩评论