Listing the stock status of products

Hello,

I get all the codes of the products from the first table as an array.
In the other table, there are products registered with unique serial numbers.

What I want to do is this.
I want to show zero 0 value in stock list for products that are not in product records.
As I show in the example below
UCE-DSO275: 20
UCE-DSO212: 18
UCE-DS0291: 15
UCE-DS0290: 12
UCE-CT221L: 9
UCE-CT220S: 5
UCE-CT220L: 0
UCE-CT213: 0
UCE-CT214: 0

// We create an array from the product codes
$productcodes = $conn->prepare("SELECT DISTINCT REGEXP_REPLACE(product_code, '-D$|-M$', '') as trimmed FROM product_codes");
$productcodes->execute();
$productcodes_arr = $productcodes->fetchAll(PDO::FETCH_COLUMN);

// With above query it is giving array like below
$productcodes_arr = array("UCE-DSO275","UCE-DSO212","UCE-DS0291","UCE-DS0290","UCE-CT221L","UCE-CT220S","UCE-CT220L","UCE-CT213","UCE-CT214");

// When each product has a unique serial number, there is a separate line for each product.
$product_quantities = $conn->query("SELECT urun_kodu,COUNT(*)
FROM products
WHERE satildi='' AND tarih=''
GROUP BY product_code
ORDER BY COUNT(*) desc");
$product_quantities->execute();
$product_quantities_arr = $product_quantities->fetchAll(PDO::FETCH_ASSOC);
Sponsor our Newsletter | Privacy Policy | Terms of Service