Hi, i really need help !!
I am developing an application that can connect to sql server using a webserver and a php file; I’ve seen several examples but I can’t connect and it doesn’t return any records.
I am using Xcode 11, SQL Server 2012 and PHP 5.5
Thanks !
have you tried running/opening just the php file itself to see if the records do return?
Yes, and if it shows me data; but nothing is displayed in the app, I am using a UIViewTable.
Thenks !
what is your code for you rowItemAt?
thats where you usually put your code to represent the data, like setting the text of a label
Hi, and thanks for answer me.
This is the code for ViewController.
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableSql: UITableView!
let sql: String = "http://myhost/ios.php"
var feedItems: NSArray = NSArray()
@IBOutlet var trailingCon: NSLayoutConstraint!
@IBOutlet var leadingCon: NSLayoutConstraint!
@IBOutlet weak var textEntry: UITextField!
let model = SqlModel()
@IBAction func textEntry(_ sender: UITextField) {
_ = SqlModel()
}
override func viewDidLoad() {
super.viewDidLoad()
model.delegate = self as? Downloadable
}
@IBAction func findSql(_ sender: Any) {
let param = ["solicitud": self.textEntry.text!]
model.downloadSql(parameters: param, url: URLServices.sql)
}
@IBAction func Consultar(_ sender: UIButton) {
let param = ["solicitud": self.textEntry.text!]
model.downloadSql(parameters: param, url: URLServices.sql)
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func itemsDownloaded(items: NSArray) {
feedItems = items
self.tableSql?.reloadData()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// Return the number of feed items
return feedItems.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Retrieve cell
let cellIdentifier: String = "id_c_telecomunicaciones"
let myCell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)!
return myCell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// Manually call segue to detail view controller
self.performSegue(withIdentifier: "id_c_telecomunicaciones", sender: self)
}
}
this code here is responsible for what you load in your tableview row, you need to make a label or something then assign a value to it based on your feedItems
Do yo have an example ?
Because all examples that i read, they haven’t a label or something for assign a value.
Thanks !
have you finished the tutorials of chris yet?, there should be codes on how to populate tableview/collectionview, the principle is the same