I am fetching data from mysql and php with alamofire data is encoded in json which is fetching fine in response now i want to decode and display in tableview how to parse data and display in tableview i have search many examples but not found my solution how to decode and display data in tableview.
<?php
if($_SERVER['REQUEST_METHOD'] == "GET")
{
$conn = mysqli_connect("localhost","id15123058_root2","Ioscrud/12345","id15123058_imageupload");
$query = mysqli_query($conn,"SELECT * FROM `ioscrud`");
while($fetch = mysqli_fetch_array($query))
{
$temp[] = $fetch;
}
$json['jobs'] = $temp;
$jsonformat = json_encode($json);
echo ($jsonformat);
}
?>
This is my php code
import UIKit
class Product:Decodable
{
var name:String
var email:String
var password:String
init(name:String,email:String,password:String) {
self.name = name
self.email = email
self.password = password
}
}
This is class
import UIKit
import Alamofire
class TableViewController: UITableViewController {
@IBOutlet var tableview: UITableView!
var product = [Product]()
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
// MARK: - Table view data source
// override func numberOfSections(in tableView: UITableView) -> Int {
// // #warning Incomplete implementation, return the number of sections
// return product.count
// }
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return product.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCell
let url = "https://jobportal475.000webhostapp.com/IosCrud/viewData.php"
AF.request(url,method: .get).response
{response in
debugPrint(response)
if response.data != nil
{
debugPrint(response)
}
}
cell.nameLabel.text = product[indexPath.row].name
cell.emailLabel.text = product[indexPath.row].email
cell.passwordLabel.text = product[indexPath.row].password
return cell
}
}
There is library for directions you can use it if you want https://github.com/akexorcist/GoogleDirectionLibrary
Or you can use this
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?
saddr="+latitude_cur+","+longitude_cur+"&daddr="+latitude+","+longitude));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Intent.CATEGORY_LAUNCHER );
intent.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent)
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
DBMS is a database management system. It is designed to change, search, add and delete information in the database. There are many DBMSs designed for similar purposes with different features. One of the most popular is MySQL.
It is a software tool designed to work with relational SQL databases. It is easy to learn even for site owners who are not professional programmers or administrators. MySQL DBMS also allows you to export and import data, which is convenient when moving large amounts of information.
https://www.mysql.com/
UIkit is another popular frontend wrapper that is arguably a little underrated in terms of CSS capabilities. In addition to many features similar to those found on other popular platforms, there are several useful specialized components.
https://getuikit.com/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.