日期:2014-05-17 浏览次数:20549 次
<div class="ch_type">
<table>
<tr>
<td>小分类的名字</td>
</tr>
<tr>
<td><p>内容1</p>
<p>内容2</p>
<p>内容3</p>
</td>
</tr>
</table>
</div>
$sqltype="select type_name,type_description,type_path,type_id from `type` where type_parent= $type_id limit 6";
$ret=mysql_query($sqltype);
$type_idarray=array();
$type_array=array();
while($rows_type=mysql_fetch_array($ret,MYSQL_ASSOC)){
$arrty=array();
$type_idarray[]=$rows_type['type_id'];小分类ID集合
array_push($arrty,count($arrty)+1,$rows_type['type_name']);//小分类名字
array_push($arrty,count($arrty)+1,$rows_type['type_description']);//小分类简介
array_push($arrty,count($arrty)+1,$rows_type['type_path']);//小分类路径
$type_array=array_pad($type_array,count($type_array)+1,$arrty);
}
$content_array=array();
foreach($type_idarray as $value) {
$type_id=$value['type_id'];
$sql_content="select content_name,content_url from `content` where type_id=$type_id limit 3";//循环三条ID下的内容
$rec=mysql_query($sql_content);
while($rows_cent=mysql_fetch_array($ret,MYSQL_ASSOC)){
$arrz=array();
array_push($arrz,count($arrz)+1,$rowzhuti_tour['content_name']);内容名字
array_push($arrz,count($arrz)+1,$rowzhuti_tour['content_url']);内容路径
$content_array=array_pad($content_array,count($content_array)+1,$arrz);
}
}
$tempc_html='type.tpl';模板
$obj_html=FILE_PATH.'/type.html';//生成静态网页路径
$smarty->assign('type_array',$type_array);//小分类的数组
$smarty->assign('content_array',$content_array);//内容的数组
$contentc = $smarty->fetch($tempc_html, null, null, false);
$fulnum=file_put_contents($obj_html,$contentc);