I am getting data from severs in json format but i want that user should send user_id while calling the json service so that it should show the desired result i am using following code
how to call the data from iphone by post passing the user_id
PHP CODE
I have used
$user_id=$_POST['user_id'];
$query = mysql_query("SELECT s.*, u.user_id FROM survey_master AS s
JOIN user_profile AS u on u.user_id = s.user_id where s.user_id=$user_id");
$rows = array();
while($row = mysql_fetch_assoc($query)) {
$rows[] = $row;
}
echo json_encode($rows);
iPhone Code
NSArray *tempArray =[[DataManager staticVersion] startParsing:@"http://celeritas-solutions.com/emrapp/surveyDescription.php"];
for (int i = 0; i<[tempArray count]; i++) {
id *item = [tempArray objectAtIndex:i];
NSDictionary *dict = (NSDictionary *) item;
ObjectData *theObject =[[ObjectData alloc] init];
[theObject setSurvey_title:[dict objectForKey:@"survey_Title"]];
[theObject setSurvey_Description:[dict objectForKey:@"survey_Description"]];
[theObject setDate_Created:[dict objectForKey:@"date_Created"]];
[surveyList addObject:theObject];
[theObject release];
theObject=nil;
}
You can use GET for sending user_id.
At PHP;
AT IPhone;