2013-01-23 37 views
0

我們試圖修改iphone文本字段中的數據,然後將(數據)返回到服務器中的mysql數據庫。如何以及在哪裏將ASIFormDataRequest合併到Xcode中?

我們有幾個問題:

是ASIFormDataRequest用於此的首選工具?如果不是,你能推薦一個並解釋如何合併? 如果ASIFormDataRequest是正確的工具,我們如何以及在哪裏將ASIFormDataRequest合併到Xcode和PHP中?

以下是包含我們編寫的代碼的三個文件,我們歡迎您提供所有的見解。感謝您的支持!

DetailViewController.h

#import <UIKit/UIKit.h> 

@interface DetailViewController : UIViewController { 
NSDictionary *newsArticle; 

IBOutlet UILabel *titleLabel; 
IBOutlet UILabel *timeLabel;  
IBOutlet UITextField *fieldname; 
IBOutlet UITextField *fieldtitle; 
IBOutlet UITextField *fielddate;} 

@property (nonatomic, copy) NSDictionary *newsArticle; 

@end 

DetailViewController.m

#import "DetailViewController.h" 

@interface DetailViewController() 

@end 

@implementation DetailViewController 
@synthesize newsArticle; 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
if (self) { 
    // Custom initialization 
} 
return self; 
} 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
// Do any additional setup after loading the view from its nib. 

titleLabel.text = [newsArticle objectForKey:@"name"]; 
timeLabel.text = [newsArticle objectForKey:@"title"]; 


fieldname.text = [newsArticle objectForKey:@"name"]; 

fieldtitle.text = [newsArticle objectForKey:@"title"]; 

fielddate.text = [newsArticle objectForKey:@"date"]; 
} 
- (void)viewDidUnload 
{ 
[super viewDidUnload]; 
// Release any retained subviews of the main view. 
// e.g. self.myOutlet = nil; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation 
{ 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

@end 

php文件

$con = mysql_connect($DB_HostName,$DB_User,$DB_Pass) or die(mysql_error()); 
mysql_select_db($DB_Name,$con) or die(mysql_error()); 

$query = mysql_query("SELECT * FROM afitest"); 

$arr = array(); 

while($row = mysql_fetch_assoc($query)) { 
$arr[] = $row; 
} 

echo json_encode($arr); 
?> 

回答

0

ASIHttprequest是一個框架(不,它不是一種工具),使您可以使http調用服務器應用程序,就像瀏覽器獲取頁面或發佈表單一樣。

不管你使用哪種數據庫 - 它既不取決於服務器腳本語言,也不取決於後端數據庫:(php或mysql)。

也就是說,有plentyexamples available什麼ASIHttpRequest可以爲你做。

如果您具體或面臨任何問題,請相應修改您的問題。你會得到更好的幫助。

相關問題