<?php

require_once __DIR__ . '/db_config.php';

$response = array();
$response["tags"] = array();

if (isset($_POST["cname"]) ) {
 
$cname=$_POST["cname"];
$id=$_POST["id"];

$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());


$tagQuery="SELECT tag_id as tagid,tagname,wieghtage as weightage,tag_created_by_mailid as tabby,tag_created_by_type as tagbytype,tag_datetime as tagcreateddatetime FROM task_tag WHERE tag_companyname='$cname' ";

if(!empty($id)){
  $tagQuery=$tagQuery." AND tag_id='$id'";
}


$tagResult=mysqli_query($con,$tagQuery);
if(!empty($tagResult) && mysqli_num_rows($tagResult) > 0){
    while ($row = mysqli_fetch_array($tagResult)) {
        array_push($response["tags"], $row);
    }
}

}

echo json_encode($response);


?>