您的位置:首页 > 编程语言 > PHP开发

Web_PHP_DedeCMS_{dede:php}标签嵌套查询使用;

2014-04-16 14:08 507 查看
{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}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: