Smarty 循环 section


<div id="content">
<div id="statistics">共{$page_count}页 {$art_count}篇文章 每页{$page_size}篇
{section name=pagelink start=1 loop=$page_count+1 step=1}
<a href="index.php?pageid={$smarty.section.pagelink.index}">{$smarty.section.pagelink.index}</a>
{/section}
</div>
{section name=article loop=$show}
<div class="post">
<h1 class="title"><font color="red">{$show[article].id}</font>  {$show[article].title}</h1>
<div class="entry">
{$show[article].content}
</div>
<div class="meta">
<p class="links"><a href="#" class="more">分类</a> <b>|</b> <a href="#" class="comments">评论</a></p>
</div>
</div>
{/section}
</div>



$db->connect();
$art_count_rs=$db->query("select * from articles");
$art_count=$db->num_rows($art_count_rs);
$page_size="5";
$page_count=ceil($art_count/$page_size);

$pageid=$_GET['pageid']?$_GET['pageid']:1;
$endid=($pageid-1)*$page_size+$page_size;
$beginid=($pageid-1)*$page_size;

$sql="select *from articles ORDER by id DESC limit $beginid,$endid";
$rs = $db->query($sql);
while($info = $db->fetch_array($rs)){
$article[]=$info;
}
$rows=$db->num_rows($rs);

$db->close();

$tpl=NEW Smarty;
$tpl->assign("art_count",$art_count);
$tpl->assign("page_size",$page_size);
$tpl->assign("page_count",$page_count);
$tpl->assign("username",$username);
$tpl->assign('show',$article);
$tpl->assign('count',$rows);
$tpl->display('index.html');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值