Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将数据从MySQL显示到NSTableView_Php_Mysql_Objective C - Fatal编程技术网

Php 将数据从MySQL显示到NSTableView

Php 将数据从MySQL显示到NSTableView,php,mysql,objective-c,Php,Mysql,Objective C,我有一个php文件从数据库中选择数据。我想在NSTableView中显示我的数据。我不知道我的php文件是真是假?我在Xcode中发布了我的phpfile和2文件.m.h。非常感谢 我的php文件: <?php $DB_HostName = "localhost"; $DB_Name = "QM_TEST"; $DB_User = "root"; $DB_Pass = ""; $con = mysql_connect

我有一个php文件从数据库中选择数据。我想在NSTableView中显示我的数据。我不知道我的php文件是真是假?我在Xcode中发布了我的phpfile和2文件.m.h。非常感谢

我的php文件:

<?php
$DB_HostName = "localhost"; 
$DB_Name = "QM_TEST";           
$DB_User = "root";          
$DB_Pass = "";              

$con = mysql_connect($DB_HostName,$DB_User,$DB_Pass) or die(mysql_error()); 
mysql_select_db($DB_Name,$con) or die(mysql_error()); 
mysql_query("SET NAMES 'utf8'");
mysql_query("set character_set_client='utf8'");
mysql_query("set character_set_results='utf8'");
mysql_query("set collation_connection='utf8'");

if(!$con)
{
    die('Connection Failed'.mysql_error());
}

$result = mysql_query("select * from EX");

$numrows = mysql_num_rows($result);
$row = array();
if ($numrows!=0){
while ($row = mysql_fetch_assoc ($result)){
    $name = $row['name'];
    $grade = $row['grade'];
    //echo "$name///";
    //echo "$grade///";

}

}else
    {
        echo "FAILED :(";   
    }
?>
我的TableArray.h

@implementation TableArray

- (id) init
{
self = [super init];
if(self) {

}
return self;
}
-(void)awakeFromNib{
[tableview1 setDataSource:self];
}

- (NSInteger) numberOfRowsInTableView:(NSTableView *)tableView
{
return [array1 count];
}

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn        *)aTableColumn row:(NSInteger)rowIndex
{
return (NSString * )[array1 objectAtIndex:rowIndex];
}

-(IBAction) list:(id)sender{
[array1 removeAllObjects];
NSString *strURL = @"http://localhost/phpFile1.php";

NSData *URLData = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];

NSString *DataResult = [[NSString alloc] initWithData:URLData encoding:NSUTF8StringEncoding];

NSArray *array = [DataResult componentsSeparatedByString:@"///"];
array1 = [[NSMutableArray alloc] initWithArray:array];
[tableview1 reloadData];
NSLog(@"%@",array1);

}

@end
#import <Foundation/Foundation.h>

@interface TableArray : NSObject <NSTableViewDataSource>{
IBOutlet NSTableView *tableview1;
NSMutableArray *array1;
}
-(IBAction) list:(id)sender;
@end

您至少应该显示实例化NSTableView的部分…您能为我解释一下吗?对不起,我的英语不好。你必须给我们提供一些代码。编辑您的问题并准确解释问题所在。如果您正在寻找为您编写代码的人,您在这里找不到。。据我所见,您只保留$name和$grade,但我没有看到任何将数据返回到您的iOS应用程序的内容。对不起,我的问题!我已经编辑了我的问题。我希望你能帮助我。谢谢布里斯!我认为我的问题是php文件中的返回值