";
//************ S T E P 1
if ($step=="1")
{
if ($parent!="-1")
{
$count="1";
$cat1=$parent;
$done="0";
$currid=$parent;
$level=$parent;
#############################################################
// Inizio percorso
while (!$done)
{
$count=$count+1;
$query="SELECT id, parent FROM category WHERE id='$level'";
$result = mysql_query($query,$db);
if ($myrow = mysql_fetch_array($result))
{
$parent_id=$myrow['id'];
$parent_parent=$myrow['parent'];
$level=$parent_parent;
${"cat".$count}=$level;
$currid=$level;
if ($orphan)
{
$count=$count-1;
$done="1";
}
if ($level=="-1")
{
$done="1";
$grandparent=$parent_id;
}
if ($level==$lastlevel)
{
$count=$count-1;
$done="1";
}
$lastlevel=$level;
}
else {$done="1";}
}
/* ---- Visualizza le categorie superiori e quella attiva ---- */
$cont = 1;
$path[0] ="$prod_base";
for ($i=$count; $i>=1; $i=$i-1)
{
$display=${"cat".$i};
// $spacer=(($count - $i) * 15);
$query="SELECT c.id, c.name, c.active, c.picture, c.description FROM category c WHERE c.id='$display'";
$result = mysql_query($query,$db);
if ($myrow=mysql_fetch_array($result))
{
$display_id=$myrow['id'];
$display_name=$myrow['name'];
$display_active=$myrow['active'];
$display_picture=$myrow['picture'];
$display_description=$myrow['description'];
$cont ++;
$titolo = $display_name;
$rif="";
$path[$cont] = "$display_name";
}
mysql_free_result($result);
}
$path = implode (" › ", $path);
$path = "".$title."".$path;
}
// fine percorso #############################################################
if ($titolo == '')
{
$titolo = $prod_base;
}
// Visualizzazione stringa path
//echo "$path ";
?>
if ($parent!="-1") { ?>
print"$display_name"; ?>
} ?>
if ($parent=="-1")
{
/* ------ Lista delle categorie per poter verificare l'esistenza di categorie 'orfane' ------ */
$catlist="0";
$query="SELECT id FROM category ";
$result = mysql_query($query,$db);
while ($myrow = mysql_fetch_array($result))
{
$cat_id=$myrow['id'];
$catlist =$catlist.",".$cat_id;
}
mysql_free_result($result);
$query="SELECT c.id, c.name, c.active FROM category c WHERE c.parent='-1' AND c.active ";
$result = mysql_query($query,$db);?>
while ($myrow=mysql_fetch_array($result))
{
$cat_id=$myrow['id'];
$cat_name=$myrow['name'];
$cat_active=$myrow['active'];
?>
### HOMEPAGE ### ?>
}
?>
|
include("box/novita.php"); ?>
mysql_free_result($result);
?>
$query="SELECT c.id, c.name, c.code, c.active FROM category c WHERE c.parent !='-1' AND c.parent NOT IN ($catlist) AND c.active ";
$result = mysql_query($query,$db);
while ($myrow=mysql_fetch_array($result))
{
$cat_id=$myrow['id'];
$cat_name=$myrow['name'];
$cat_active=$myrow['active'];
?>
}
mysql_free_result($result);
}
else
{
/* ------- [Categoria già selezionata] --------- */
$count="1";
$cat1=$parent;
$done="0";
$currid=$parent;
$level=$parent;
/* ------- [Conta le categorie superiori] --------- */
while (!$done)
{
$count=$count+1;
$query="SELECT id, parent FROM category WHERE id='$level'";
$result = mysql_query($query,$db);
if ($myrow = mysql_fetch_array($result))
{
$parent_id=$myrow['id'];
$parent_parent=$myrow['parent'];
$level=$parent_parent;
${"cat".$count}=$level;
$currid=$level;
if ($orphan)
{
$count=$count-1;
$done="1";
}
if ($level=="-1")
{
$done="1";
$grandparent=$parent_id;
}
if ($level==$lastlevel)
{
$count=$count-1;
$done="1";
}
$lastlevel=$level;
}
else {$done="1";}
}
/* ---- Visualizza le categorie superiori e quella attiva ---- */
for ($i=$count; $i>=1; $i=$i-1)
{
$display=${"cat".$i};
$query="SELECT c.id, c.name, c.active, c.picture, c.description FROM category c WHERE c.id='$display'";
$result = mysql_query($query,$db);
if ($myrow=mysql_fetch_array($result))
{
$display_id=$myrow['id'];
$display_name=$myrow['name'];
$display_active=$myrow['active'];
$display_picture=$myrow['picture'];
$display_description=$myrow['description'];
if ($display_id==$parent)
{
$catname=$display_name;
if ($display_picture!="none") {$haspic=1; $catpicture=$display_picture;}
else {$haspic=0;}
if ($display_description=="none") {$catdescription="";}
else {$catdescription=$display_description;}
}
}
mysql_free_result($result);
}
/* ---- Visualizza le categorie sotto a quella attiva ----- */
$query="SELECT c.id, c.code, c.name, c.active FROM category c WHERE c.parent='$parent' AND c.active";
$result = mysql_query($query, $db);
?>
while ($myrow = mysql_fetch_array($result))
{
$display_id=$myrow['id'];
$display_name=$myrow['name'];
$display_code=$myrow['code'];
$display_active=$myrow['active'];
?>
}?>
mysql_free_result($result);
?>
//Prova calcolo prodotti
if (!isset($numc))
{
$numc=5;
$begin=0;
}
if (!isset($pagina)) $pagina=1;
// Serve solo per contare il numero totale di news
$pre_query="SELECT DISTINCT p.novita as novita ,p.discount as discount, p.catalogoid as catalogoid , p.shortdesc as shortdesc, p.picture as picture,p.marcaid as marcaid, p.catalogoid as catalogoid, p.id AS id, p.name as name, p.sell AS sell, cl.catid AS catid FROM products p, catlink cl WHERE p.id=cl.prodid AND p.active=1 AND cl.catid='$parent' AND p.deleted=0 ";
$result_num= mysql_query($pre_query,$db);
$tot_ricerca=mysql_num_rows($result_num);
if ($tot_ricerca > 0)
{
// ci sono news
$num_pagine=ceil($tot_ricerca / $numc);
// Se la pagina è la 1 partiamo da 0
$begin=($pagina-1) * $numc;
/* ----- Mostra i prodotti della categoria ------ */
$query="SELECT DISTINCT p.novita as novita ,p.discount as discount, p.catalogoid as catalogoid , p.shortdesc as shortdesc, p.picture as picture,p.marcaid as marcaid, p.catalogoid as catalogoid, p.id AS id, p.name as name, p.sell AS sell, cl.catid AS catid FROM products p, catlink cl WHERE p.id=cl.prodid AND p.active=1 AND cl.catid='$parent' AND p.deleted=0 order by p.marcaid, p.name LIMIT $begin, $numc";
$result = mysql_query($query,$db);
while ($myrow = mysql_fetch_array($result))
{
mysql_assign($query,$myrow,"display_");
if ($display_picture=='none' || $display_picture=='')
{$this_img="";
unset($w);
unset($h);
;}
else
{$this_img="prodimg/$display_picture";
$h = "height='100'";
$w = "width='150'";
}
/*$qq = "select * from produttori where id = '$display_marcaid'";
$resultM = mysql_query($qq,$db);
$myrow = mysql_fetch_array($resultM);*/
if ($i) { $i=false; $colore="#F9F9F9"; }
else {$i=true; $colore="#FFFFFF"; }
/*$qq2 = "select * from catalogo where id = '$display_catalogoid'";
$resultC = mysql_query($qq2,$db);
$myrowC = mysql_fetch_array($resultC); */
?>
} ?>
}
?>
$query="SELECT DISTINCT * FROM category WHERE id='$parent'";
$result = mysql_query($query,$db);
while ($myrow = mysql_fetch_array($result))
{
mysql_assign($query,$myrow,"disp_");
$temp = explode ("_",$disp_linkid);
for ($i=0;$i
Marche e siti di riferimento
$query= "select * from produttori where 0 $qry";
$result = mysql_query($query,$db);
while ($myrow = mysql_fetch_array($result))
{
mysql_assign($query,$myrow,"resp_");
if ($i) { $i=false; $colore="#F9F9F9"; }
else {$i=true; $colore="#FDFDFD"; }
?>
">
|
">
echo"$resp_link"; ?>
|
} ?>
}
?>
echo"
"; if ($haspic) {echo"";
}
}
}
if ($step=="2")
{
$query = "SELECT * FROM products WHERE id=$pid AND deleted=0";
$result = mysql_query($query,$db);
if($myrow = mysql_Fetch_array($result))
{
mysql_assign($query,$myrow,"this_");
$esaurito = false;
$found=1;
}
else
{
$found=0;
}
mysql_free_result($result);
if (!$found)
{
echo $prodottoinesistente;
}
else
{
// ++++++++++++++++++++++
/*$qq = "select * from produttori where id = '$this_marcaid'";
$resultM = mysql_query($qq,$db);
$myrowM = mysql_fetch_array($resultM);*/
// ++++++++++++++++++++++
// ++++++++++++++++++++++
/*$qq2 = "select * from catalogo where id = '$this_catalogoid'";
$resultC = mysql_query($qq2,$db);
$myrowC = mysql_fetch_array($resultC);*/
// ++++++++++++++++++++++
if(!$catid)
{
$query="SELECT catid FROM catlink WHERE prodid=$pid";
$result=mysql_query($query,$db);
if ($myrow=mysql_fetch_array($result))
{
$catid=$myrow['catid'];
}
else
{
$catid=-1;
}
mysql_free_result($result);
}
$hasfield=0;
if ($this_picture!="none") {$haspic=1;}
else {$haspic=0;}
if ($this_url!="none") {$hasurl=1;}
else {$hasurl=0;}
//$weight=formatPrice($this_weight,-1);
//if ($this_voleven) {$volprice=$this_volprice*$this_volqty;}
//else {$volprice=$this_volprice*1;}
if ($this_sell > 0) {
// $volprice= formatPrice($volprice,2);
$price=formatPrice($this_sell,2);
$price="€ ".$price;
}
// *****
$next_catid=$catid;
$cat_path="";
while($next_catid!=-1)
{
$query="SELECT c.name,c.parent FROM category c WHERE c.id=$next_catid";
$result=mysql_query($query);
if($myrow=mysql_fetch_array($result))
{
$cat_name=$myrow['name'];
$cat_parent=$myrow['parent'];
$cat_path=" › ".$cat_name."".$cat_path;
}
else {
$cat_parent=-1;
}
mysql_free_result($result);
$next_catid=$cat_parent;
}
$cat_path="".$title."".$cat_path;
//*****
//echo"$cat_path ";
?>
echo" Articolo $this_name "; ?> |
if ($this_novita) echo" | "; ?>
if ($haspic) { ?> " alt=" echo"$this_name"; ?>" width="375" border="0"> |  |  | } ?>
echo"$this_shortdesc"; ?> |
echo"$this_description"; ?> |
|
<% if ($this_sell > 0) {
// VISIBILE SOLO SE PREZZO INSERITO%>
echo"$price"; ?> |
<% } %>
|
|
}
}
?>
@mysql_close();
?>
include("inc/footer_catalogo.php"); ?>
include("inc/footer.php"); ?> |