日期:2014-05-17 浏览次数:20443 次
<div>
<dl>
<dt>
<?php
$strSql1 ="Select id From menu where subs_pid='13' Order By time ASC limit 0,11";
$res1 = _query($strSql1);
while (!!$rs=_fetch_array($res1)){
$subID = $rs['id'];
echo "<span><a href=\"/#\" >地板(等建材栏目)</a></span>\n";
}
mysql_free_result($res1);
?>
</dt>
<?php
$strSql2 ="select pic1 from newslist where n_ppid='".$subID."' order by n_time desc limit 0,12";
//$subID为建材栏目ID...如何通过第一步循环的建材栏目ID.循环出对应的建材图片
?>
<dd><div>吊顶产品图片</div></dd>
<dd><div>门窗产品图片</div></dd>
<dd><div>地板产品图片</div></dd>
<dd><div>家电产品图片</div></dd>
</dl>
</div>
$strSql1 = "Select id From menu where subs_pid='13' Order By time ASC limit 0,11";
$res1 = _query($strSql1);
while (!!$rs=_fetch_array($res1)){
$subID[] = $rs['id'];//注意这里
echo "<span><a href=\"/#\" >地板(等建材栏目)</a></span>\n";
}
mysql_free_result($res1);
foreach($subID as $id) {
echo '<dd><div>';
$strSql2 ="select pic1 from newslist where n_ppid='".$id."' order by n_time desc limit 0,12";
//这里是循环输出图片的代码
echo '</div></dd>';
}