	<?php

	 include 'configi.php';

	$querycat="SELECT * from ".$_COOKIE['phxcrmclient_id']."web_cat";

	$resultcat=mysqli_query($conn, $querycat);

	while($rowcat=mysqli_fetch_array($resultcat)) { 

		$cat_id			 				= $rowcat['cat_id'];
		$cat_item_count = 0;

		$queryttlcat="SELECT count(".$_COOKIE['phxcrmclient_id']."prodserv.uid) as count FROM ".$_COOKIE['phxcrmclient_id']."prodserv LEFT JOIN (".$_COOKIE['phxcrmclient_id']."prod_category LEFT JOIN ".$_COOKIE['phxcrmclient_id']."web_cat ON ".$_COOKIE['phxcrmclient_id']."prod_category.cat_id = ".$_COOKIE['phxcrmclient_id']."web_cat.cat_id) ON ".$_COOKIE['phxcrmclient_id']."prodserv.uid = ".$_COOKIE['phxcrmclient_id']."prod_category.prod_uid WHERE ".$_COOKIE['phxcrmclient_id']."web_cat.cat_id = ".$cat_id. " and  ".$_COOKIE['phxcrmclient_id']."prodserv.prod_status='Active'";
		
	//	echo $queryttlcat;
		

	//	$result = $result . $queryclient;
		$resultttlcat=mysqli_query($conn, $queryttlcat);
		while($rowttlcat=mysqli_fetch_array($resultttlcat)) { 

			$cat_item_count 				= $rowttlcat['count'];
			
			
		}
		
		
		$queryupdate = "update ".$_COOKIE['phxcrmclient_id']."web_cat set cat_count = " . $cat_item_count . " where cat_id = " . $cat_id;
		
		echo "<br>";
		echo $queryupdate;
		
		$updatettlcat=mysqli_query($conn, $queryupdate);
		
		
	}
	