PDA

View Full Version : Connecting to a remote database...




ac1
Jan 17, 2011, 03:31 PM
First post, hi!

I am looking to create a 'simple' iphone app that shows the location of updates from nearby users. A user can insert an update (along with location, which I can get as a longitude,latitude) and then this is updated to some database online and the latest x updates are downloaded and put on a map as pins (which again I can do using MKAnnotations)... question is how would I upload and download data to the database.

TIA.



dejo
Jan 17, 2011, 03:50 PM
The simplest answer? Web Services (http://en.wikipedia.org/wiki/Web_services).

Let us know if you have more specific needs, and we'll see if we can provide you more specific direction.

ac1
Jan 19, 2011, 11:28 AM
I've created a mySQL database and the PHP to go with it which allows me to insert data into the table.

Now, I'm thinking I could just use NSURLRequest to upload "http://site.com/database/upload.php?lat=%@&long=%@&update=%@"

problem is I can't quite see how exactly I'd get this to work.

I haven't started thinking about downloading the data back to the app, but I suppose I could write more PHP to help me.

EDIT: Fixed NSURL Request...

I'm going to output each row from the table as a JSON object, and then write a for loop over each row to place a pin on the map.