views:

465

answers:

2

Hi all,

I am having a php file and a mysql database. i need to load the data from my mysql database to the iphone. can anyone help me in this. What is the best way to do that.

Thanks in advance. Shibin Moideen A. K

A: 

I don't know much about Iphone App programming. But you can output the database content in XML on a website (or make this file available to download) and import this file to your iphone. you just need to write (or get somewhere) a parser, which can convert the xml file and store the data on your iphone.

Hayt
+2  A: 

Create a web service which can take parameters through GET or POST and output the data in JSON or XML. For example, your iphone app can make a request to a url like

http://example.com/services/getPosts.php?userId=43

Here its passing the parameter through GET, but you can also use HTTP POST to post the data to the web service URL. The web service at getPosts.php will validate the id, and either return an XML list of all the posts/rows which are found, or a JSON object.\

To convert an array to JSON, you will use json_encode(). To convert an array to XML, see this question.

Click Upvote
Thanks for your answer..
Shibin Moideen
You're welcome, perhaps can accept it by clicking the checkbox next to it?
Click Upvote