dede模板中直接寫sql語句,關聯sql調用


<div>{dede:php}$row = $GLOBALS['dsql']->GetOne("select id from dede_archives where typeid=4  order by rand() LIMIT 1"); 
 $row2 = $GLOBALS['dsql']->GetOne("select body from dede_addonarticle where aid=".$row['id']);
  $pattern='/key=(.*?)"/';
  $arr = preg_match($pattern, $row2['body'],$mc);
  $str = $mc[1];
  preg_replace("/\s/", "",$str);
  print_r('<iframe width="700" height="400" src="'.$str.'" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>');{/dede:php}
</div>

上圖匹配一個網址如圖key的部分:

 

若dede:php標簽不管用,下圖(或dede:php  runphp='yes' )

模板引擎禁用標簽中,去掉“php”即可;

------------------------------------------------------------

另:plus下模板中可直接寫php代碼,如下:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM