绍兴专业、认真、靠谱、值得信赖的网站建设团队!了解详情

08科技_www.08keji.com

当前位置: 主页 > 技术 > PHP >

PHP之在Dede中使用SQL

时间:2017-03-11 22:50来源:08科技(www.08keji.com) 作者:08科技 点击:
一、基本用法: {dede:sqlsql=SELECT t1.id id, t1.title title, t1.senddate senddate, t2.typedir typedir FROM dede_archives t1 LEFT JOIN dede_arctype t2 ON t1.typeid=t2.id WHERE t1.typeid IN (SELECT id FROM dede_arctype WHERE id=16 OR t
 
 
一、基本用法:
 
{dede:sqlsql="SELECT t1.id id, t1.title title, t1.senddate senddate, t2.typedir typedir FROM dede_archives t1 LEFT JOIN dede_arctype t2 ON t1.typeid=t2.id WHERE t1.typeid IN (SELECT id FROM dede_arctype WHERE id=16 OR topid=16) AND t1.flag LIKE '%c%' AND t1.ismake=1 AND t1.arcrank=0 ORDER BY t1.senddate DESC LIMIT 0,5"}
<li><a href="[field:typedir runphp='yes']@me = str_replace('{cmspath}', '', @me);[/field:typedir]/[field:senddate runphp='yes']@me = date('Y', @me);[/field:senddate]/[field:senddate runphp='yes']@me = date('md', @me);[/field:senddate]/[field:id/].html" title="[field:title/]">[field:title/]</a></li>
{/dede:sql}
 
 
 
 
二、高级用法:
1、dede后台->系统->系统设置->系统基本参数->其它选项->把“模板引擎禁用标签”中的"php"标签去掉,保存
2、使用:
 
{dede:php}
$result = mysql_query("select * from bbs_forum_forum t1 left join bbs_forum_forumfield t2 on t1.fid=t2.fid where status=1 and type='forum' order by t1.displayorder asc");
while($row = mysql_fetch_assoc($result)){
     echo '<table cellpadding="0" cellspacing="0" width="100%" border="0" class="pbw_bbsTable">';
     echo '<tr>';
     echo '<td width="64">';
     echo '<a href="/bbs/forum.php?mod=forumdisplay&fid='.$row['fid'].'"><img src="/bbs/data/attachment/common/'.$row['icon'].'" width="46" height="46" style="border:1px solid #000;" /></a>';
     echo '</td>';
     echo '<td width="465">';
     echo '<div class="pbw_bbsTitle"><a href="/bbs/forum.php?mod=forumdisplay&fid='.$row['fid'].'">'.$row['name'].'</a><span>('.$row['threads'].')</span></div>';
     echo '<div class="pbw_bbsBrief">'.$row['description'].'</div>';
     echo '<div style="color:red;">'.$row['rules'].'</div>';
     $moderators = explode("    ", $row['moderators']);
     $moderators = implode(",", $moderators);
     echo '<div class="pbw_bbsBanzhu">版主:'.$moderators.'</div>';
     echo '</td>';
     echo '<td width="90">&nbsp;</td>';
     echo '<td width="120" align="center">';
     echo $row['threads'].'/'.$row['posts'];
     echo '</td>';
     echo '<td>';
     $lastpost = explode("    ", $row['lastpost']);
     echo '<a href="/bbs/forum.php?mod=viewthread&tid='.$lastpost[0].'#lastpost">'.$lastpost[1].'</a>(<a href="/bbs/home.php?mod=space&username='.$lastpost[3].'" style="color:#369">'.$lastpost[3].'</a>)<br />';
     echo date("Y-m-d H:i:s", $lastpost[2]);
     echo '</td>';
     echo '</tr>';
     echo '</table>';
}
{/dede:php}
  
(责任编辑:08科技)
顶一下
(1)
100%
踩一下
(0)
0%
------分隔线----------------------------