0
Table PRODUTOS
- id
- nomedoproduct
- categoriadoproduct
- valordoproduct
Table CATEGORIAS
- id
- nomedacategoria
In my form I show the name of the category but register in the database in the table PRODUTOS
the id of the same that I imagine is the right thing to do.
I have to show the product and its category in a view. Then I query and get as category the number 1
in product view through instruction:
<?php while($PA = $BuscaProdutosAtivos->fetch()){ ?>
Nome do produto: <?=$PA['prod_nome']?>
Categoria do produto: <?=$PA['prod_categoria']?>
Valor do produto: <?=$PA['prod_valor']?>
<?php } ?>
How to search in the table CATEGORIA
the nomedacategoria
to insert into the view once I have the ID
of the category in question?
Get the category name in the same SELECT as you get the products by making a JOIN. http://dev.mysql.com/doc/refman/5.0/en/join.html
– Caffé