<?php
include("include/config.php");
include("pages.php");	
$id_nav=intval($_GET[id]);
	$father="select * from `bigclass_nav` where fid=$id_nav";
	$father_res=query($father);
	while ($father_info=mysql_fetch_array($father_res)) {
		//$subs_id=$subs_id.$father_info[id].",";
		$subs_id=$subs_id.$father_info[id].",";
	}
	$subs_id.=$id_nav;
	//$subs_id=substr($subs_id,0,(strlen($subs_id)-1));
	
	$sql="SELECT * FROM `bigclass_nav` where id='$id_nav'";
	$result=query($sql);
	while ($info=mysql_fetch_array($result)) {
		$nav_id=$info[id];
		$nav_name=$info[cname];
		
	};
	$smarty->assign('nav_name',$nav_name);
	if ($id_nav == 2) {
	$sql_list_total="SELECT * FROM `product`";
	}else {
	
	$sql_list_total="SELECT * FROM `product` where typeid in ($subs_id)";
	}
	$result_list_total=query($sql_list_total);
	$total=mysql_num_rows($result_list_total);
	pageft($total,8);
	if ($id_nav == 2) {
	$sql_list="SELECT * FROM `product` order by id desc limit $firstcount,$displaypg";
	}else {
	$sql_list="SELECT * FROM `product` where typeid in ($subs_id) order by id desc limit $firstcount,$displaypg";
	}
	$result_list=query($sql_list);
	$n=2;
	while ($info_list=@mysql_fetch_array($result_list)) {
		$n++;
		$img_url='admin/'.$info_list[img];
		$img=@imagecreatefromjpeg($img_url);
		$img_width= imagesx($img);
		$img_height= imagesy($img);
		$bili= ($img_width / $img_height);
		$height=(250 /$bili);
		$list.="<td><a href='show_product.php?id=".$info_list[id]."'><img border='0' src='admin/".$info_list[img]."' width='250' height='".$height."' title='".$info_list[title]."'></a> &nbsp;</td>";
		if (($n % 2) == 0) {
		$list.="</tr><tr>";
		}
	};
	
	$smarty->assign('pagenav',$pagenav);
	$smarty->assign('list',$list);	
	$smarty->display("list_product.html");

?>
