{dede:php}
// 第一次查询
$fsql = 'SELECT a.id,a.title,a.litpic,d.expert,d.introduction FROM dede_archives as a,dede_addondisease as d WHERE a.id = d.aid GROUP BY d.expert ORDER BY a.pubdate DESC LIMIT 3';
$db->Execute('first', $fsql);
while($farr = $db->GetArray('first')) {
$expert = $farr["expert"];
$title = $farr["title"];
$introduction = mb_substr($farr["introduction"],0,20,'gbk');
echo '<li>';
echo ' <span><a href="/plus/view.php?aid='.$farr["id"].'"><img src="'.$farr["litpic"].'" width="90" height="75" /></a></span>';
echo ' <h4><a class="blue" href="/plus/view.php?aid='.$farr["id"].'" style="line-height:18px;">'.$title.'</a></h4>';
echo ' <p>'.$expert.'</p>';
echo ' <p>'.$introduction.'...<a href="/plus/view.php?aid='.$farr["id"].'" class="red" target="_blank">[查看详细]</a></p>';
// 第二次查询(嵌套)
$ssql = 'SELECT a.id,a.title FROM dede_archives as a,dede_addondisease as d WHERE a.id = d.aid and d.expert = "'.$expert.'" and a.title != "'.$title.'" ORDER BY a.pubdate DESC LIMIT 2';
$db->Execute('second', $ssql);
while($sarr = $db->GetArray('second')) {
echo '<a class="blue" style="line-height:18px;" href="/plus/view.php?aid='.$sarr["id"].'" >'.$sarr["title"].'</a><br />';
}
echo '</li>';
}
{/dede:php}