<?php

// Created by Ilhomjon on 06.03.2021
header('Content-type: text/html; charset=UTF-8');
require "connect.php";


$sql = "SELECT `region_id`, `kontr_id`, `kontr_nomi`, `qarzi_som`, `qarzi_val`,`telefon`, `max_sum`, `max_val`,`lat`,`lang`,`time` FROM `kontragentlar` WHERE 1";

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)){

        $region_id=$row['region_id'];
        $dokon_id=$row['kontr_id'];
		$nomi=$row['kontr_nomi'];
		$qarzi_som=$row['qarzi_som'];
        $qarzi_val=$row['qarzi_val'];
		$max_val=$row['max_val'];
        $max_sum=$row['max_val'];
        $lat=$row['lat'];
        $lang=$row['lang'];
		$time=$row['time'];
		$telefon=$row['telefon'];

		$nomi = str_replace('"', '`', $nomi);

    	array_push($list_kontr,
                array(
                        'region_id' => $region_id,
                        'kontr_id' => $dokon_id,
                        'kontr_nomi' => $nomi,
                        'qarzi_som' => $qarzi_som,
                        'qarzi_val' => $qarzi_val,
                        'max_sum' => $max_sum,
                        'max_val' => $max_val,
                        'lat' => $lat,
                        'lang' => $lang,
                        'time' => $time,
                        'telefon'=>$telefon
                     )
                  );

		}

    }

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