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

{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}		

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值