<?php 

require 'db.php';
// $data = json_decode(file_get_contents('php://input'), true);
 
// $uid = $data['uid'];
// if($uid == '')
// {
// 	$returnArr = array("ResponseCode"=>"401","Result"=>"false","ResponseMsg"=>"Something Went wrong  try again !");
// }

$sels = $con->query("select * from category");
while($rows = $sels->fetch_assoc())
{
    $p['id'] = $rows['id'];
	$p['catname'] = $rows['catname'];
	$p['cattime'] = $rows['cattime'];
	if($p['cattime'] == "Default")
	{
	    $sel = $con->query("select start_time,end_time from setting where id='1'");
        if($row = $sel->fetch_assoc())
        {
            $p['catstarttime'] = $row['start_time'];
            $p['catstoptime'] = $row['end_time'];
        }
	}
	else
	{
	    $p['catstarttime'] = $rows['catstarttime'];
	    $p['catstoptime'] = $rows['catstoptime'];
	}
	$p['catimg'] = $rows['catimg'];
	$p['count'] = $con->query("select * from subcategory where cat_id=".$rows['id']."")->num_rows;
	$p['catstatus'] = $rows['catstatus'];
	$cp[] = $p;
}

echo json_encode($cp);
?>