<?php
include("../db.php");

$s = $_POST['s'];
$e = $_POST['e'];

$txt = "select * from `pro` ";
$query = mysqli_query($db,$txt);
while($row = mysqli_fetch_assoc($query))
{
	$id_cata = $row['id_pro'];
	$name_cata = $row['name_pro'];
	$txt1 = "select sum(q) as `t` from `sales` left join `pro` on `pro`.`id_pro` = `sales`.`id_pro`  where `sales`.`id_pro` = '$id_cata' and `sales`.`date` between '$s' and '$e' ";
	$query1 = mysqli_query($db,$txt1);
	$row1 = mysqli_fetch_assoc($query1);
	$value = $row1['t'];
	$data[] = array("name_cata" => $name_cata,"value" => $value);
}
echo json_encode($data);
?>