1
Some time ago I made an attempt to relate products, but it did not become functional and I believe it was also not the most correct form, I confess, the same is bad, what I did was basically this:
I search the lines (Categories) and just below where the checks list the products of this category and select the product I want to relate, this can be seen in this image:
My cheks are set up like this:
<input type="checkbox" name="produto[]" id="produto[]" value="<?php echo $row_produtos['id_produto']; ?>" /><?php echo $row_produtos['codigo']; ?>
I’m limiting the amount of 10 products, I’m confused and I can’t understand what I should record in my bank, the id_product, id_categoria to later search and show on my page.
What I’d like to know is, how is the right way to develop this solution and visual, how would the register?
A product can have N categories that’s it?
– rray
Hello @rray, that’s right.
– adventistapr
I had a similar doubt, see if this resolves http://stackoverflow.com/q/23160254/1518921 (the idea of the question is a product with several prices, should help you), of course I used double at the time for being totally lay, but this has nothing to do with the problem hehehehehe, Just ignore, otherwise you might want to read this: http://answall.com/a/6448/3635, of course, if you want to show the product you won’t always need to do the relationship
– Guilherme Nascimento
You will need a table for products, categories and a call possibly
produto_categoria
who has theid
of the product and theid
of the category at least.– rray
Yes, @array, these tables I already have, including with the names you have.
– adventistapr
The question is when to use PHP to record? the product id comes from form with vc can take the category ids and do a foreach to register in the table of
produto_categoria
– rray
The category ids I believe, should stay in my checks, ai caught them by foreach, my crucial doubt was what to record in the bank.
– adventistapr
That’s right, the product id should be an Hidden input
– rray