I am trying to load the table by fetching data from the external database using PHP. I have the script on the server, and able to fetch the data. I'm trying to get help and understand the logic, but still I cant get it.
At the moment, I have only set up my tableview but there is not data.
Please let me know how can I fetch the data.
Thanks
code:
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
    var group = [Group]()
    @IBOutlet weak var tableview: UITableView!
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        tableview.reloadData()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        //return myarray.count
        return 1
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "groupCell", for: indexPath) as! UITableViewCell
       // cell.textLabel?.text = myarray[indexPath.item]
        return cell
    }
}
Code:(how can I get the data displayed on the table view)?
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
//let myarray = ["item1", "item2", "item3"]
var group = [Group]()
@IBOutlet weak var tableview: UITableView!
override func viewDidLoad() {
    super.viewDidLoad()
    let url = URL(string: "http://www.myurl/myfile.php")
    let task = URLSession.shared.dataTask(with: url! as URL) { data, response, error in
        guard let data = data, error == nil else { return }
        print(NSString(data: data, encoding: String.Encoding.utf8.rawValue))
    }
    task.resume()        
}
override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    tableview.reloadData()
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    //return myarray.count
    return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "groupCell", for: indexPath) as! UITableViewCell
   // cell.textLabel?.text = myarray[indexPath.item]
    return cell
}
}
 
     
    