1.统计数量
[field:title runphp='yes'] global $dsql; $me=@me; //@me 为中文 $sql="select count(*) as c from dede_addonimages_anli where xqmc=N'$me'"; //中文数据用 N'中文' 查询 $value = $dsql->GetOne($sql); @me=$value['c']+20; //在统计的基础上+20 [/field:title]
2.调用一条数据输出多个参数
[field:id runphp=yes] global $dsql; $id = @me; $sql='select * from dede_archives where typeid='.$id; $row=$dsql->getone($sql); $description = cn_substr($row[description],120); //截取 120 个字符 $url = GetOneArchive($row[id]); $url = $url['arcurl']; //数据库没有直接输出 arcurl 的值 需要经过 GetOneArchive 查询 @me =<<<str <h3><a target="_blank" href="$url" title="$row[title]">$row[title]</a></h3> <p>$description</p> </dt> str; [/field:id]
3.调用多条数据输出多个参数
[field:bianhao runphp=yes]
global $dsql;
$id = @me; //bianhao 为自定义字段,根据自定义字段查询出 B(_tpj)表中 jlbh 等于当前 biaohao 且 aid 等于 A 表中 id 的值 输出 6 条
$sql='select id,title from dede_archives,dede_addonimages_tpj where dede_archives.id=dede_addonimages_tpj.aid and dede_addonimages_tpj.jlbh='.$id.' limit 6';
$dsql->SetQuery($sql); //将 SQL 查询语句格式化
$dsql->Execute(); //执行 SQL 操作
//通过循环输出执行查询中的结果
while($row = $dsql->GetArray()){
$url = GetOneArchive($row[id]);
$url = $url['arcurl'];
$str .=<<<str
<a href="$url">$row[title]</a>
str;
@me = $str;
}
[/field:bianhao]

