Função PHp

mail@pastecode.io avatar
unknown
php
8 months ago
805 B
1
Indexable
Never
public function deptojson($data)
{
    $nom_depart = $data["term"];

    if (!empty($nom_depart) && strlen($nom_depart) >= 5) {

        $response = array();

        $sql = "SELECT * FROM ???? WHERE nom_depart LIKE '{$nom_depart}%' AND ies_cod_versao = '0'";
        $res = ifx_query($sql, Connect::banco("???"));

        while ($row = ifx_fetch_row($res)) {
            array_push($response, array(
                'depto' => trim($row['nom_depart']),
                'coddp' => trim((int)$row['cod_depart']),
                'label' => trim($row['nom_depart']) . '('.(int)$row['cod_depart'].')',
                'value' => trim($row['nom_depart'])
            ));
        }

        echo json_encode($response);
        ifx_close(Connect::banco("logix"));
        exit;
    }
}
Leave a Comment