<?php

// Created by Olloyor on 06.03.2021

require_once('connect.php');

$sql = "SELECT agent_id, fio, boshagan, telefon, parol, region_idlar, kontr_idlar, gruppa_idlar, can_zakaz, can_tolov, can_otchot  FROM agentlar ";

mysqli_set_charset($conn,"utf8");
$result = mysqli_query($conn,"SET NAMES utf8");

$result = mysqli_query($conn, $sql);

$count=1;

$list_kontr = array();

if ($result !== false && $result->num_rows > 0) {
    while($row=mysqli_fetch_array($result)){


        $agent_id=$row['agent_id'];
        $fio=$row['fio'];
        $fio=str_replace('"', '|', $fio);
        $boshagan=$row['boshagan'];
        $telefon=$row['telefon'];
        $parol=$row['parol'];
        $region_idlar=$row['region_idlar'];
        $kontr_idlar=$row['kontr_idlar'];
        $gruppa_idlar=$row['gruppa_idlar'];
        $can_zakaz=$row['can_zakaz'];
        $can_tolov=$row['can_tolov'];
        $can_otchot=$row['can_otchot'];


        array_push($list_kontr,
                array(
                        'agent_id' => $agent_id,
                        'fio' => $fio,
                        'boshagan' => $boshagan,
                        'telefon' => $telefon,
                        'parol' => $parol,
                        'region_idlar' => $region_idlar,
                        'kontr_idlar' => $kontr_idlar,
                        'gruppa_idlar' => $gruppa_idlar,
                        'can_zakaz' => $can_zakaz,
                        'can_tolov' => $can_tolov,
                        'can_otchot' => $can_otchot
                     )
                  );

        }

    }

echo json_encode($list_kontr);
$conn->close();
?>

