<?php

// Created by Ibrohimjon Ahmadjonov Ilhomjon o'g'li on 02.10.2020
header('Content-type: text/html; charset=UTF-8');
require "connect.php";


$umum_soni = 0;

$sql = "SELECT Id,user_id,dokon_id,tovar_id,soni,narxi,naqd_per,vaqti,zakaz_raqam, doc_turi FROM zakazlar WHERE yuklandi ='0'  ORDER BY Id ASC";

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

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

$count=1;
$idlar = "0";

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

		$id=$row['Id'];
		$user_id=$row['user_id'];
		$dokon_id=$row['dokon_id'];
		$tovar_id=$row['tovar_id'];
		$soni=$row['soni'];
		$narxi=$row['narxi'];
		$narx_turi=$row['naqd_per'];
		$vaqti=$row['vaqti'];
		$zakaz_raqam=$row['zakaz_raqam'];
		$doc_turi=$row['doc_turi'];
		$idlar = $idlar.",".$id;

// 		 	$mysql_qry = "UPDATE zakazlar SET yuklandi=1 WHERE Id = '".$id."'";
// 			if($conn->query($mysql_qry) == TRUE){

					 echo nl2br("".$user_id."^".
						$dokon_id."^".
						$tovar_id."^".
						$soni."^".
						$narxi."^".
						$narx_turi."^".
						$zakaz_raqam."^".
						$vaqti."^".
						$doc_turi."~");

					$count++;
// 			}
	}
	if($count > 1){

date_default_timezone_set('Asia/Tashkent');
        $timestamp = time();
        $date_time = date("d.m.Y H:i:s", $timestamp);

		echo "|".$date_time."|".$idlar;
		$conn->close();
		return;
	}
}

if($count == 1){

	echo "no";
	$conn->close();
	return;
} else{

	echo "no";
	$conn->close();
	return;
}


$conn->close();
?>
