Home >php教程 >php手册 >Smarty来实现表格颜色交替显示

Smarty来实现表格颜色交替显示

WBOY
WBOYOriginal
2016-06-21 08:54:511012browse

 以前没有用SMARTY的时候要实现表格颜色的交替显示,会用JQUERY来做,但现在的话用了SMARTY,要实现这个样式就很简单了,SMARTY提供了一个函数:cycle.以下是实例代码: 

最后实现的效果如下: 
 


test.php>>> 

include_once("smarty_inc.php"); 
$arr=array("a","b","c","d","e","f"); 
$smarty->assign("arr",$arr); 
$smarty->display("test.tpl"); 
?> 


test.tpl>>> 

 
{section name=a loop=$arr} 
{cycle values="#eeeeee,#55eero"}"> 
 
 
{/section} 
 
{$arr[a]} 
 

以上就代码,使用起来很方便. 




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP streamNext article:phpMyAdmin简明安装教程