This question is an exact duplicate of:
In my PHP file, I have this code:
$user_id = $_POST['user_id'];
require_once('Connect.php');
$sql = "SELECT * FROM Loans WHERE user_id='$user_id'";
I check it in HTML and it works. Nothing's wrong with it. However, when I try to put it in Swift, I have a problem with that. I don't how will I put value of "user_id" from Swift file to PHP file then go back to Swift to execute the PHP file.
Here's my Swift code:
if let loanArray = jsonObj!.value(forKey: "loans") as? NSArray
{
for loans in loanArray
{
if let loanDict = loans as? NSDictionary
{
if let name = loanDict.value(forKey: getBnum)
{
self.borrNoArray.append(name as! String)
}
if let name = loanDict.value(forKey: "loan_no")
{
self.loanNoArray.append(name as! String)
}
if let name = loanDict.value(forKey: "amount")
{
self.loanAmtArray.append(name as! String)
}
OperationQueue.main.addOperation({
self.tableView.reloadData()
})
}
}
}
I already tried this Swift code and it also works. I have a default value for "user_id", it is 0 and I just add some info about it just for me to see if my Swift code works and it is.
</div>