smarty传值给HTML用户名,smarty怎么传值?

下面是我现在的代码:

index.tpl{section name=arr loop=$rst max=2 start=0}

{if $smarty.section.arr.index<2 }

{* <?php  for($i=0;$i<2;$i++){

$row=mysql_fetch_array($_result);

list(  $year,$month ,  $day  ) = preg_split  ( '[/.-]' , $news_date );*}

{*注释是原来的php代码*}

{$day}
{$year}{$month}
{$rst[arr].news_title|truncate:"32":"...":"true"}

{/if}

{/section}

{* <?php  }?> *}

index.php<?php

require_once('include.php');

$sql="select * from tb_news where news_type='4' order by news_date DESC";

$rst = $admindb->ExecSQL($sql,$conn);

$rst_news_img=$rst[0]["news_img"];

for($i=0;$i<2;$i++){

$news_date=$rst[$i]["news_date"];

}

list(  $year, $month, $day  ) = preg_split  ( '[/.-]' , $news_date );

//$htgl=$_GET["htgl"];

$smarty->assign('rst',$rst);

$smarty->assign('rst_news_img',$rst_news_img);

$smarty->assign('year',$year);

$smarty->assign('month',$month);

$smarty->assign('day',$day);

$smarty->display('index.tpl');

?>

像我这样做只能传固定的三个值($year, $month, $day ),

由于不能把逻辑控制部分放在tpl,但是不放在那里循环,得到的又只能是固定的值,根本不能对应起来。

怎么才能传对应的值?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值