how to filter data with json and php

0

I need someone to help me, I have a structure that receives data from a mysql database, I would like to show the data in the app but filtering the data that matches a variable I defined when loading the app, I have the following structure :

func datos3(){

        let url = URL(string: "http://test/test.php")

        Alamofire.request(url!).responseJSON { (response) in

            let result = response.data
            do {
                self.filtro = try JSONDecoder().decode([ClientDADES].self, from: result!)
                DispatchQueue.main.async {
                    self.tabla.reloadData()
                }
            } catch {
                print("Error al conectar php", error)
            }
        }

    }

and in php:

<?php

    $servername = "test";
    $database = "test";
    $username = "test";
    $password = "test";

    $conn = mysqli_connect($servername, $username, $password, $database);

    $conn-> set_charset('utf-8');


        $resultado = array();
        $temporal= array();

        $conn->query("SET NAMES UTF8");

    $sel = $conn ->query("SELECT * FROM 'Cli'");

    while ($f = $sel->fetch_assoc()) {
       $temporal = $f;

       // $temporal = $f;
        array_push($resultado, $temporal);
    }

    echo json_encode($resultado);

    $sel->close();
    $conn->close();

    ?>
    
asked by Miquel Molina 20.12.2018 в 14:36
source

0 answers