queryAll("SELECT id,nome FROM categorias_$lang WHERE activo='1' ORDER BY ord"); $nmcats = count($mcats); for($i=0; $i<$nmcats; $i++) { $mcats[$i]['subcats'] = $DB->queryAll("SELECT id,nome FROM subcategorias_$lang WHERE id_categoria=".$mcats[$i]['id']." AND activo='1' ORDER BY ord"); $mcats[$i]['nsubcats'] = count($mcats[$i]['subcats']); for($j=0; $j<$mcats[$i]['nsubcats']; $j++) { $mcats[$i]['subcats'][$j]['items'] = $DB->queryAll("SELECT id,nome FROM items_$lang WHERE id_cat=".$mcats[$i]['subcats'][$j]['id']." AND activo='1' ORDER BY ord"); } } if(!$id_item) { if(!$id_subcat) { if(!$id_cat) { $id_cat = $DB->queryOne("SELECT id FROM categorias_$lang WHERE activo='1' ORDER BY ord LIMIT 1"); } $id_subcat = $DB->queryOne("SELECT id FROM subcategorias_$lang WHERE id_categoria=$id_cat AND activo='1' ORDER BY ord LIMIT 1"); } $id_item = $DB->queryOne("SELECT id FROM items_$lang WHERE id_cat=$id_subcat AND activo='1' ORDER BY ord LIMIT 1"); } if($id_item) { $item = $DB->queryRow("SELECT * FROM items_$lang WHERE id=$id_item"); $imgs = $DB->queryAll("SELECT * FROM items_img_$lang WHERE id_item=$id_item ORDER BY ord"); if(!$id_subcat) $id_subcat = $item['id_cat']; $subcat_nome = $DB->queryOne("SELECT nome FROM subcategorias_$lang WHERE id=$id_subcat"); if(!$id_cat) $id_cat = $DB->queryOne("SELECT id_categoria FROM subcategorias_$lang WHERE id=$id_subcat"); $cat_nome = $DB->queryOne("SELECT nome FROM categorias_$lang WHERE id=$id_cat"); $subcats = $DB->queryAll("SELECT id,nome FROM subcategorias_$lang WHERE id_categoria=$id_cat AND activo='1' ORDER BY ord"); $nsubcats = count($subcats); $items = $DB->queryAll("SELECT id,nome,(select img from items_img_$lang where id_item=i.id ORDER BY ord LIMIT 1) AS img FROM items_$lang i WHERE id_cat=$id_subcat AND activo='1' ORDER BY ord"); $nitems = count($items); } else { $item = array(); $imgs = array(); } require('header.php'); ?>
image
1) { ?> image image
image