0
I’m making a virtual store, but I’m not able to display the products of the subcategory on the page.
Category products will be normal, but sub-category products will not.
Follows the code:
<?php
$categoria = $_GET['categoria'];
$categoria_sub = $_GET['categoria_sub'];
$sql = mysql_query("SELECT * FROM produto
INNER JOIN categoria
ON produto.categoria = categoria.categoria_id
INNER JOIN categoria_sub
ON produto.categoria_sub = categoria_sub.sub_cat_id
WHERE produto.categoria = '".$categoria."'
AND produto.categoria_sub = '".$categoria_sub."'
ORDER BY RAND()");
if (mysql_num_rows($sql)== true) {
while ($ln = mysql_fetch_assoc($sql)) {
?>
Tables:
put the structure of your tables and some record as an example, if possible use Sqlfiddle
– Rovann Linhalis
edited post with the table
– Betinho Silva
Must-read: Why should we not use mysql type functions_*?
– Woss
@Betinhosilva where ?
– Rovann Linhalis
@Rovannlinhalis I just put in
– Betinho Silva
if a sub-category belongs to a category, as a product may belong to a category x, and to a sub-category y where y is not a sub-category of x ?
– Rovann Linhalis