<?php

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


$umum_soni = 0;

$us_id = $_GET['id'];
$count=1;

$sql_sorov = "SELECT us.user_id AS user_id, us.fio AS fio,us.naqd AS naqd,us.perech AS perech,us.optom AS optom,us.nasiya AS nasiya, us.telefon AS telefon, us.parol AS parol, us.huquqi AS huquqi, us.region_idlar AS region_idlar, us.kontr_idlar AS kontr_idlar, gen.holati AS holati, us.brend_idlar AS brend_idlar FROM users AS us INNER JOIN generatsiya AS gen ON us.user_id = gen.user_id WHERE us.user_id = '$us_id' AND us.boshagan = '0'";

mysqli_set_charset($conn,"utf8");
$javob = mysqli_query($conn,"SET NAMES utf8");
$javob = mysqli_query($conn, $sql_sorov);
if ($javob !== false && $javob->num_rows > 0) {
    while($row=mysqli_fetch_array($javob)){

        $Id=$row['user_id'];
        $fio=$row['fio'];
		$fio=str_replace('"', '|', $fio);
		$telefon=$row['telefon'];
		$parol=$row['parol'];
    	$naqd=$row['naqd'];
    	$perech=$row['perech'];
    	$optom=$row['optom'];
    	$nasiya=$row['nasiya'];
		$huquqi=$row['huquqi'];
		$holati=$row['holati'];
		$kontr_idlar=$row['kontr_idlar'];
		$region_idlar=$row['region_idlar'];
    	$brend_idlar=$row['brend_idlar'];
        
		if($kontr_idlar == ""){
		    $kontr_idlar = "0";
		}

		if($region_idlar == ""){
		    $region_idlar = "0";
		}

	    echo ''.$Id.'^'.$fio.'^'.$telefon.'^'.$parol.'^'.$huquqi.'^'.$holati.'^'.$region_idlar.'^'.$kontr_idlar.'^'.$naqd.'^'.$perech.'^'.$optom.'^'.$nasiya.'^'.$brend_idlar.'~';
		$count++;

		$conn->close();
		return;
	}
}
if($count == 1){

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

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


$conn->close();
?>
