<?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.boshagan AS holati, us.naqd AS naqd, us.perech AS perech, us.optom AS optom, us.nasiya AS nasiya, us.prays1 AS prays1, us.prays2 AS prays2, us.dostuplar AS dostuplar, us.telefon AS telefon, us.parol AS parol, us.huquqi AS huquqi, us.region_idlar AS region_idlar, us.kontr_idlar AS kontr_idlar, us.brendlar AS brendlar FROM users AS us 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'];
		$brendlar=$row['brendlar'];
		$prays1=$row['prays1'];
		$prays2=$row['prays2'];
		$dostuplar=$row['dostuplar'];

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

		if($region_idlar == ""){
		    $region_idlar = "0";
		}
      
		if($brendlar == ""){
		    $brendlar = "0";
		}
		if($holati == "0"){
		    $holati = "1";
		} else if($holati == "1"){
		    $holati = "0";
		}

	    echo ''.$Id.'^'.$fio.'^'.$telefon.'^'.$parol.'^'.$huquqi.'^'.$holati.'^'.$region_idlar.'^'.$kontr_idlar.'^'.$naqd.'^'.$perech.'^'.$optom.'^'.$nasiya.'^'.$brendlar.'^'.$prays1.'^'.$prays2.'^'.$dostuplar.'~';
		$count++;
 
		return;
	}
}
if($count == 1){

	echo "no_c"; 
	return;
} else{

	echo "no_c"; 
	return;
}


$conn->close();
?>
