phpcms v9栏目列表调用每一篇文章内容方法

{pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"}
<ul class="list lh24 f14">
{loop $data $r}
<li><span class="rt">{date('Y-m-d H:i:s',$r[inputtime])}</span>·<a href="{$r[url]}" target="_blank"{title_style($r[style])}>{$r[title]}</a>
<?php $id = $r['id'];
$sql = "SELECT `content` FROM `cmsyou_news_data` WHERE `id`='$id' LIMIT 0 , 1";
$query = mysql_query($sql);
while($row=mysql_fetch_array($query)){
echo $row[content];
}
?>
</li>
{if $n%5==0}<li class="bk20 hr"></li>{/if}
{/loop}
</ul>
<div id="pages" class="text-c">{$pages}</div>
{/pc}

其中,下面这段代码调用了对应的Content:

<?php $id = $r['id'];
$sql = "SELECT `content` FROM `cmsyou_news_data` WHERE `id`='$id' LIMIT 0 , 1";
$query = mysql_query($sql);
while($row=mysql_fetch_array($query)){
echo $row[content];
}
?>

是直接用SELECT调用指定数据表的对应id内容。

posted @ 2015-03-14 16:57  秋月白  阅读(368)  评论(0编辑  收藏  举报