MySQL Connection to Android via PHP and JSON

KozmoK

New Member
I have a mysql database with the following table that i need to be displayed in my android app. The table is called "users" and has the following: 4 columns (name, received_power, tower, status). In the name column there is data like: "User 1" (so basically its not a number). Now, the following is my PHP code in a file called C:\wamp\www\android_test\fetch_data2.php \[code\]<?phpmysql_connect("host","*****","*****");mysql_select_db("******");$q=mysql_query("SELECT * FROM users");while($row=mysql_fetch_assoc($q))$output[]=$row;print(json_encode($output));mysql_close();?>\[/code\]I access this through going on 127.0.0.1/android_test/fetch_data2.phpand it show up like this: [{"name":"User1","received_power":"201.88181554850496","tower":"3","status":"0"},{"name":"User2","received_power":"233.69793182377703","tower":"1","status":"0"}]I want it to show up as an array or table just like in MySQL but in my android application and thats all i need to do.Ive been following some online tutorials, but it is still unclear to me how to get this done.Here are the websites im using for my tutorials:fahmirahman.wordpress.com/2011/04/21/connection-between-php-server-and-android-client-using-http-and-json/www.hassanpur.com/blog/2010/09/android-development-implementing-a-simple-client-server-model/Now i just need to display the data on my application in a table like it is on MySQL and that is all my application has to do. Just take a look at the the tutorials above and if you could help i would really appreciate it.Thanks a lot in advance
 
Back
Top