Hi ya'll I am building an app and I trying to get data to display on my app via MySQL and PHP.
I have looked at some tutorials and I tried to make sense of them and this what I have come up with...
This is my php file which is located on my server GetData.php
$mysqli = new mysqli("myhostingserver", "username", "password", "database");
$result = $mysqli->query("SELECT id, CASE open when 1 then 'Yes' when 0 then 'No' END as open, date, time, extra1, extra2, lastUpdated FROM MyTable");
and this is what I put on my ViewController.h file in xcode
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (retain, nonatomic) IBOutlet UILabel *YesOrNo;
@end
and this is the code from my ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *strURL = [NSString stringWithFormat:@"http://myhostingserver.com/GetData.php"];
// to execute php code
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
// to receive the returend value
NSString *strResult = [[[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding]autorelease];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc {
[_YesOrNo release];
[super dealloc];
}
@end
I think this seems right, but how do I get the data of open in the textbox?
would it be something along the lines of *YesOrNow = *strResult['open']?
I ran my app with the code above, no errors just a warning that says *strResult is an unused variable...please help