<?php

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



$sql = "SELECT Id, gruppa_id, tovar_id, nomi, valyuta_turi, kirim_narxi_som, kirim_narxi_val, sotish_narxi_chakana_som, sotish_narxi_chakana_val, sotish_narxi_per_som, sotish_narxi_per_val,sotish_narxi3_som, sotish_narxi3_val,sotish_narxi4_som, sotish_narxi4_val, blokdagi_soni, qoldiq, can_narx, time FROM tovarlar ";

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

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

$count=1;

$list_tovarlar = array();

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

        $gruppa_id=$row['gruppa_id'];
        $tovar_id=$row['tovar_id'];
        $nomi=$row['nomi'];
        $valyuta_turi=$row['valyuta_turi'];
        $kirim_narxi_som=$row['kirim_narxi_som'];
        $kirim_narxi_val=$row['kirim_narxi_val'];
        $sotish_narxi_chakana_som=$row['sotish_narxi_chakana_som'];
        $sotish_narxi_chakana_val=$row['sotish_narxi_chakana_val'];
        $sotish_narxi_per_som=$row['sotish_narxi_per_som'];
        $sotish_narxi_per_val=$row['sotish_narxi_per_val'];
        $sotish_narxi3_som=$row['sotish_narxi3_som'];
        $sotish_narxi3_val=$row['sotish_narxi3_val'];
        $sotish_narxi4_som=$row['sotish_narxi4_som'];
        $sotish_narxi4_val=$row['sotish_narxi4_val'];
        $blokdagi_soni=$row['blokdagi_soni'];
        $qoldiq=$row['qoldiq'];
        $can_narx=$row['can_narx'];
		$time=$row['time'];

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

         array_push($list_tovarlar,
            array(
                    'gruppa_id' => $gruppa_id,
                    'tovar_id' => $tovar_id,
                    'nomi' => $nomi,
                    'valyuta_turi' => $valyuta_turi,
                    'kirim_narxi_som' => $kirim_narxi_som,
                    'kirim_narxi_val' => $kirim_narxi_val,
                    'sotish_narxi_chakana_som' => $sotish_narxi_chakana_som,
                    'sotish_narxi_chakana_val' => $sotish_narxi_chakana_val,
                    'sotish_narxi_per_som' => $sotish_narxi_per_som,
                    'sotish_narxi_per_val' => $sotish_narxi_per_val,
                    'sotish_narxi3_som' => $sotish_narxi3_som,
                    'sotish_narxi3_val' => $sotish_narxi3_val,
                    'sotish_narxi4_som' => $sotish_narxi4_som,
                    'sotish_narxi4_val' => $sotish_narxi4_val,
                    'blokdagi_soni' => $blokdagi_soni,
                    'qoldiq' => $qoldiq,
                    'can_narx' => $can_narx,
                    'time' => $time
                 )
                );

		$count++;
	}

}

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