<?php

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

 
$umum_soni = 0;  

// $sql = "SELECT me.Id AS Id, me.menu_id AS menu_id, me.nomi AS nomi, COALESCE(SUM(tovar.menuga_soni),0) AS soni FROM menular AS me LEFT JOIN tovarlar AS tovar ON me.menu_id = tovar.menu_id GROUP BY me.menu_id";

$sql = "SELECT me.Id AS Id, me.menu_id AS menu_id, me.nomi AS nomi, me.rasmi AS rasmi FROM menular AS me";

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

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

$count=1;

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

		$Id=$row['Id']; 
		$user_id=$row['menu_id']; 
		$nomi=$row['nomi']; 
		$rasmi=$row['rasmi']; 
		$soni="0"; 
		
		$nomi = str_replace('"', '`', $nomi); 
		
		echo ''.$Id.'^'.$user_id.'^'.$nomi.'^'.$soni.'^'.$rasmi.'~';
 
		$count++;
	}
	if($count > 1){ 
		$conn->close();
		return;
	}
}

if($count == 1){
	
	echo "no_c";
	$conn->close();
	return;
} else{
	 
	$conn->close();
	return;
}

$conn->close();
?>