<?php
foreach($idd as $ids)
{
$sql5 = "select count(DISTINCT product_name) as total from stock where type = '".$ids."'";
$result5 = mysqli_query($con,$sql5);
$row5 = mysqli_fetch_row($result5);
}
$total5 = $row5[0];
?>
In this code I have used explode function for $idd and run query inside foreach loop and want to sum of multiple query inside foreach loop and Now, My query look like:
select count(DISTINCT product_name) as total from stock where type = 'Green Tea'select count(DISTINCT product_name) as total from stock where type = 'Herbal Tea'
But I want like this
select (select count(DISTINCT product_name) as total from inventory_add_in_stock where type = 'Green Tea')+(select count(DISTINCT product_name) as total from inventory_add_in_stock where type = 'Herbal Tea') as total
So, How can I do this? Please help me.
Thank You