-2

I am trying to figure out how to display a product with the sizes that it has. Now it is displayed with duplication.

My product table

My product specification table

'Maat' being sizes and 'Voorraad' being stock

Here is my query:

$sql = "SELECT * FROM producten JOIN product_specificaties";
  • You can read the docs: https://dev.mysql.com/doc/refman/8.0/en/join.html . You need a "join specification", with `ON` clause – Felippe Duarte Nov 16 '20 at 17:49

2 Answers2

1

Try this

$sql = "
SELECT *
  FROM producten p
  JOIN product_specificaties s
    ON p.id = s.product_id
";
Strawberry
  • 33,750
  • 13
  • 40
  • 57
  • Thanks for your help. Now the products display without duplicate, but it displays like this: Barakah Shirt (S), Barakah Shirt (M). How can I prevent it from showing the same product but with different size? – Nabil Den Haag Nov 16 '20 at 18:18
  • well you can just print it together with the naam and maat like this echo $row["naam"]."(".$row["maat"].")"; – user9726751 Nov 17 '20 at 03:17
0

Returns general information, you can use select or other items, say if you have something specific

SELECT * FROM producten INNER JOIN product_specificaties ON
producten.id=product_specificaties.product_id;