<?php

// Created by Mr. Developer on 15.09.2020

header("Content-type:application/json");

require_once('connect.php');

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

$query = mysqli_query($conn, "SELECT Id, brend_id, tovar_id, nomi, narxi_naqd, narxi_per, narxi_optom, narxi_nasiya, qoldiq, blok_soni, time, skidka, skidka_eski FROM tovarlar ");

$response = array();

while($row = mysqli_fetch_assoc($query)){

        $Id=$row['Id'];
		$brend_id=$row['brend_id'];
		$tovar_id=$row['tovar_id'];
		$nomi=$row['nomi'];
		$narxi_naqd=$row['narxi_naqd'];
		$narxi_per=$row['narxi_per'];
		$narxi_optom=$row['narxi_optom'];
		$narxi_nasiya=$row['narxi_nasiya'];
		$qoldiq=$row['qoldiq'];
		$blok_soni=$row['blok_soni'];
		$time=$row['time'];
		$skidka=$row['skidka'];
		$skidka_eski=$row['skidka_eski'];

		$nomi = str_replace('"', '`', $nomi);
       $qoldiq = str_replace(',', '.', $qoldiq);
    array_push($response,
    array(
            'Id' => $Id,
            'brend_id' => $brend_id,
            'tovar_id' => $tovar_id,
            'nomi' => $nomi,
            'narxi_naqd' => $narxi_naqd,
            'narxi_per' => $narxi_per,
            'narxi_optom' => $narxi_optom,
            'narxi_nasiya' => $narxi_nasiya,
            'qoldiq' => $qoldiq,
                'blok_soni' => $blok_soni,
            'time' => $time,
            'skidka' => $skidka,
            'skidka_eski' => $skidka_eski
         )
        );
}

echo json_encode($response);

?>
