我试图找到如何在我的 iphone 应用程序中从我的数据库中读取数据。数据库在我的服务器中,我尝试的方法类似于我在 Android 中的操作方式(我不确定是否是最好的方法):
NSString *hostStr = @"http://www.myip/notices.php";
NSData *dataURL = [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]];
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];
NSLog(@"Mysql response:is %@",serverOutput);
我得到的是“Mysql 响应:是数组”,这是真的:
<?php
mysql_connect("localhost","user","pass");
mysql_select_db("database");
$q = mysql_query("SELECT id, title FROM jos_content WHERE catid=12 AND state=1 AND DATE(publish_up) <= NOW() ORDER BY DATE(publish_up) DESC");
while($e=mysql_fetch_assoc($q))
$output[]=array("id" => $e['id'], "title" => utf8_encode($e['title']));
echo $e;
print($output);
mysql_close();
?>
我该怎么做?
先感谢您