S
S
samorez7772018-06-14 17:29:17
MySQL
samorez777, 2018-06-14 17:29:17

Need help, many-to-many?

How to display specific images by id_img:
product table:

id title   id_img
1  Nike     1,2,3
2  Puma      1,2
3  Lux      3,4,5

img table:
id   img
1    1.png
2    2.png
3    3.png

How to display custom images for each product?
I will have output in a foreach loop for a variable
$products= \R::getAll("SELECT * FROM product_status JOIN product ON product.status_id = product_status.id JOIN pay ON product.paysystem_id = pay.pay_id");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2018-06-14
@samorez777

Products
----------------
id title
1  Nike
2  Puma
3  Lux

Images
--------------
1 1.jpg
2 2.jpg
3 3.png

pivotProductsImages
----------------
1 1
1 2
2 1
2 3
3 2
3 1
3 3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question