Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code> @implementation FromDataBase - (void)viewDidLoad { [super viewDidLoad]; //Load Password and Username NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; LoadUsername = [defaults objectForKey:@"TheUsername"]; NSUserDefaults *pass = [NSUserDefaults standardUserDefaults]; LoadPassword = [pass objectForKey:@"ThePassword"]; //Gets the php FindURL = [NSString stringWithFormat:@"http://localhost/FromDB/DB.php?username=%@",LoadUsername]; // to execute php code URLData = [NSData dataWithContentsOfURL:[NSURL URLWithString:FindURL]]; // to receive the returend value DataResult = [[NSString alloc] initWithData:URLData encoding:NSUTF8StringEncoding]; FriendsArray = [DataResult componentsSeparatedByString:@"///"]; NSLog(@"%@", FriendsArray); SearchFriends = [[NSMutableArray alloc] initWithArray:FriendsArray]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [SearchFriends count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; } cell.textLabel.text = [SearchFriends objectAtIndex:indexPath.row]; return cell; } - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ TheSellected = [SearchFriends objectAtIndex:indexPath.row]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:TheSellected message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; return; } @end </code></pre> <p>And Now the PHP:</p> <pre><code>&lt;?php if (isset ($_GET["username"])) $username = $_GET["username"]; else{ $username = ""; } //DateBase Infomation $DB_HostName = "localhost"; $DB_Name = "Users"; $DB_User = "root"; $DB_Pass = ""; $DB_Table = Friends; //Connecting To Database $con = mysql_connect($DB_HostName,$DB_User,$DB_Pass); mysql_select_db($DB_Name,$con); if(!$con) { die('Connection Failed'.mysql_error()); } $result = mysql_query("select * from $DB_Table "); $numrows = mysql_num_rows($result); if ($numrows!=0){ while ($row = mysql_fetch_assoc ($result)){ $Friends = $row['Friends']; echo "$Friends///"; } }else{ echo "FAILED :("; } ?&gt; </code></pre> <p>I hope this will help you :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload