我正在从服务器获取 json 格式的数据,但我希望用户在调用 json 服务时发送 user_id,以便它应该显示我正在使用以下代码的所需结果
如何通过传递 user_id PHP 代码从 iphone 调用数据
我用过
$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 代码
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;
}