Hi folks - I’ve undertaken the job of trying to make a print catalog for a customer of mine by taking the data from her Zen Cart store’s database and displaying it in individual php pages that can be printed.
I managed to draw data from the ZC database to make a page where all the items are listed and there’s a photo, price, description etc. by joining a couple tables together:
$query = "
SELECT * FROM products
LEFT JOIN products_description
ON
products.products_id = products_description.products_id
GROUP BY products.products_id
";
My problem comes when I try to refine the query so that I can do the same thing while selecting only the products with a certain category id. My aim is to make a page that only contains items from the category in question, so each category gets its own page (or pages) in the print catalog.
So I tried this:
$query = "
SELECT * FROM products where master_categories_id = 3
UNION
SELECT * FROM products
LEFT JOIN products_description
ON
products.products_id = products_description.products_id
GROUP BY products.products_id
";
but I get the error “the used SELECT statements have a different number of columns”.
Obviously I’m missing something here! Any help with either refining my query or understanding why this doesn’t work would be helpful.