upload array of items to json API ios -
i have ios app can upload data such string json , phpmyadmin database.
[[api sharedinstance] commandwithparams:[nsmutabledictionary dictionarywithobjectsandkeys:@"uploaddata", @"command", titletext.text, @"title", nil] oncompletion:^(nsdictionary *json) { //completion nslog(@"json: %@", json); if (![json objectforkey:@"error"]) { //success [[[uialertview alloc]initwithtitle:@"success!" message:@"your data has uploaded" delegate:nil cancelbuttontitle:@"done" otherbuttontitles: nil] show]; } else { //error, check expired session , if - authorize user nsstring* errormsg = [json objectforkey:@"error"]; [uialertview error:errormsg]; if ([@"authorization required" compare:errormsg]==nsorderedsame) { [self performseguewithidentifier:@"showlogin" sender:nil]; } } }];
however, add array of items tableview.
[[api sharedinstance] commandwithparams:[nsmutabledictionary dictionarywithobjectsandkeys:@"uploadguests", @"command", self.tabledata, @"names", nil] oncompletion:^(nsdictionary *json) { //completion nslog(@"json: %@", json); if (![json objectforkey:@"error"]) { //success [[[uialertview alloc]initwithtitle:@"success!" message:@"your table data has uploaded" delegate:nil cancelbuttontitle:@"done" otherbuttontitles: nil] show]; } else { //error, check expired session , if - authorize user nsstring* errormsg = [json objectforkey:@"error"]; [uialertview error:errormsg]; if ([@"authorization required" compare:errormsg]==nsorderedsame) { [self performseguewithidentifier:@"showlogin" sender:nil]; } } }];
i use api.php to upload database works if data string or int not array.
$result = query("insert namestable(names) values('%s')", $names);
my question best way upload table data json?
Comments
Post a Comment