I’m linking my app with a MySQL database via a PHP script that I’m using to send and get data from my iPhone app.
I’m able to get data if it’s only one variable, via the response string from PHP, but what do you do if you want to get many element from a table in your database, for example?
Getting all the variables you need from your PHP script and encoding them into JSON is going to be the best solution to bring it into your iPhone application efficiently. In PHP you’ll create an array of elements like so (all the variables you want your app to have access to):
Then we’ll translate the array into JSON:
Which we can then return that $json variable via your PHP script. Bringing it into your iOS application I suggest looking into JSONKit as it’s one of the best performing JSON third party tools you can use for such a task:
https://github.com/johnezang/JSONKit