<?php
include_once('smarty.inc.php');
include_once('class.inc.php');
function query($sql) {
mysql_query("set names 'gbk'");
$result=mysql_query($sql);
return $result;
}

//首页的导航
$sql="SELECT * FROM `bigclass_nav` where yiid=0 and fid=0";
$result=query($sql);
while ($info=mysql_fetch_array($result)) {
	if ($info[id] == 2) {
		$navigation.="<li><a href='list_product.php?id=".$info[id]."'>".$info[cname]."</a></li>";
	} else {
		if ($info[id]==3 || $info[id] == 1) {
			$navigation.="<li><a href='nav.php?id=".$info[id]."'>".$info[cname]."</a></li>";
		}else {
			$navigation.="<li><a href='list.php?id=".$info[id]."'>".$info[cname]."</a></li>";
		}
	}
};
$smarty->assign('navigation',$navigation);
//首页的网站信息


$smarty->assign('webname',$webname);
$smarty->assign('phone',$phone);
$smarty->assign('Email',$Email);
$smarty->assign('ICP',$ICP);
$smarty->assign('logo',$logo);
$smarty->assign('url',$url);
$smarty->assign('title',$title);
$smarty->assign('keywords',$keywords);
$smarty->assign('description',$description);

//公告信息
$sql_announcement="select * from gonggao order by id desc";
$result_anno=query($sql_announcement);
$info_anno=mysql_fetch_array($result_anno);
$content=$info_anno[content];
$smarty->assign('announcement',$content);
 //公司简介
$sql_introduce="SELECT * FROM `bigclass_nav` where id='1'";
$result_introduce=query($sql_introduce);
$info_introduce=mysql_fetch_array($result_introduce);
$introduce=$info_introduce[content];
$smarty->assign('introduce',$introduce);
//产品展示
$sql_product="SELECT * FROM `product` where Home_t='首页推荐' limit 0,30";
$result_product=query($sql_product);
while ($info_product=mysql_fetch_array($result_product)) {
		$img_url='admin/'.$info_product[img];
		$img=@imagecreatefromjpeg($img_url);
		$img_width= imagesx($img);
		$img_height= imagesy($img);
		$bili= ($img_width / $img_height);
		$width=(87 * $bili);
	$product.="<a href='show_product.php?id=".$info_product[id]."'><img title='".$info_product[title]."' width='$width' height='87' border='0'  src='admin/".$info_product[img]."'></a>";
};
$smarty->assign('product',$product);

//幻灯片展示
$sql_ppt="SELECT * FROM `product` where ppt=1";
$result_ppt=query($sql_ppt);
while ($info_ppt=mysql_fetch_array($result_ppt)) {
	$ppt.="admin/".$info_ppt[img]."|";
};
$ppt=substr($ppt,0,(strlen($ppt)-1));

$smarty->assign('ppt',$ppt);
//投票模块问题
$sql_vote="SELECT * FROM `voteclass` where jihuo='1'";
$result_vote=query($sql_vote);
while ($info_vote=mysql_fetch_array($result_vote)) {
	$Votename=$info_vote[VoteName];
	$Voteid=$info_vote[VoteID];
	$class=$info_vote['class'];
	
	
};
$smarty->assign('Votename',$Votename);
$smarty->assign('Voteid',$Voteid);
//投票模块选项
$sql_vote_sub="SELECT * FROM `vote` left join `voteclass` on  `vote`.voteid=$Voteid and `vote`.voteid=`voteclass`.VoteID";
$result_vote_sub=query($sql_vote_sub);
while ($info_vote_sub=mysql_fetch_array($result_vote_sub)) {
	if ($class == 'checkbox') {
		$class='checkbox[]';
	}
	$vote_sub.="<p>&nbsp;&nbsp;<label><input name='".$class."' value='".$info_vote_sub[id]."' type='".$info_vote_sub['class']."' />&nbsp;".$info_vote_sub[Votetitle]."</label></p>";
};
$smarty->assign('vote_sub',$vote_sub);

//投票结果处理
$vote_answer=$_POST[$class];

if ($vote_answer) {
	if (!is_array($vote_answer)) {
		$vote_answer=intval($vote_answer);
		$sql_vote_ans="update vote set totalnum=(totalnum + 1) where id = $vote_answer";
		query($sql_vote_ans);
		echo "<script>alert('投票成功，谢谢您的参与')</script>";
	}else {
		foreach ( $vote_answer as $v ) {
		$sql_vote_ans="update vote set totalnum=(totalnum + 1) where id = $v";
		query($sql_vote_ans);
		}
		
	}
	echo "<script>alert('投票成功，谢谢您的参与')</script>";
}



//新闻中心
$sql_news="SELECT * FROM `bigclass_nav` where fid=4 order by id desc";
$result_news=query($sql_news);
while ($info_news=mysql_fetch_array($result_news)) {
	$title_news.="<li><a href='list_product.php?id=".$info_news[id]."'>".substr($info_news[cname],0,42)."</a></li>";
	
};
$smarty->assign('title_news',$title_news);

//成功案例
$sql_case="SELECT * FROM `bigclass_nav` where fid=5 order by id desc";
$result_case=query($sql_case);
while ($info_case=mysql_fetch_array($result_case)) {
	$title_case.="<li><a href='list_product.php?id=".$info_case[id]."'>".substr($info_case[cname],0,42)."</a></li>";
	
};
$smarty->assign('title_case',$title_case);

//公司业务
$sql_service="SELECT * FROM `news` where yiid='3' order by ID desc limit 0,5";
$result_service=query($sql_service);
while ($info_service=mysql_fetch_array($result_service)) {
	$title_service.="<li><a href='#'>".substr($info_service[title],0,24)."</a></li>";
	
};
$smarty->assign('title_service',$title_service);
//寻找父目录






?>