<?php

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



$sql = "SELECT Id, agent_id, kontr_id, malumot, vaqti, zakaz_raqam, zakaz_int, yuklandi, holati,dastavshik_id, time_update, time_create FROM zakaz WHERE holati IN (0,1)";

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

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

$count=1;

$list_zakaz = array();

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

        $zakaz_id=$row['Id'];
        $agent_id=$row['agent_id'];
        $kontr_id=$row['kontr_id'];
        $malumot=$row['malumot'];
        $vaqti=$row['vaqti'];
        $zakaz_raqam=$row['zakaz_raqam'];
        $zakaz_int=$row['zakaz_int'];
        $yuklandi=$row['yuklandi'];
        $holati=$row['holati'];
        $dastavshik_id=$row['dastavshik_id'];
        $time_update=$row['time_update'];
        $time_create=$row['time_create'];

         array_push($list_zakaz,
            array(
                    'zakaz_id' => $zakaz_id,
                    'agent_id' => $agent_id,
                    'kontr_id' => $kontr_id,
                    'malumot' => $malumot,
                    'vaqti' => $vaqti,
                    'zakaz_raqam' => $zakaz_raqam,
                    'zakaz_int' => $zakaz_int,
                    'yuklandi' => $yuklandi,
                    'holati' => $holati,
                    'dastavshik_id' => $dastavshik_id,
                    'time_update' => $time_update,
                    'time_create' => $time_create,
                 )
                );

		$count++;
	}

}

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