行变色

php页面

<?php
include "libs/Smarty.class.php";
$smarty = new Smarty();

$link = mysql_connect('localhost','root','123');
mysql_select_db('ecshop',$link);
mysql_query("set names utf8");

$sql = "select * from ecs_brand";
$result = mysql_query($sql);
$rows = array();
while($row = mysql_fetch_assoc($result)){
 $rows[] = $row;
}
$smarty -> assign('list',$rows);
$smarty -> display('1.html');

模板页面设计

<body>
<table>
<tr>
<th>商品id</th>
<th>商品名称</th>
<th>商品logo</th>
<th>商品描述</th>
</tr>

{foreach from=$list item='value' key='k' name='color'}
{if $smarty.foreach.color.iteration%2== 0}
<tr bgcolor="blue">
<td>{$value.brand_id}</td>
<td>{$value.brand_name}</td>
<td>{$value.brand_logo}</td>
<td>{$value.brand_desc}</td>
</tr>
{else}
<tr bgcolor="red">
<td>{$value.brand_id}</td>
<td>{$value.brand_name}</td>
<td>{$value.brand_logo}</td>
<td>{$value.brand_desc}</td>
</tr>
{/if}
{/foreach}
</table>
</body>

利用Smarty实现文本隔行变色的更多相关文章

  1. jquery实现html表格隔行变色

    效果图 实现代码: 通过css控制样式,利用jquery的addClass方法实现 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Trans ...

  2. 我的第一个jQuery插件--表格隔行变色

    虽然网上有大量的插件供我们去使用,但不一定有一款适合你的,必要的时候还是要自己动手去敲的.下面,开始我的第一个插件... 参考<锋利的JQuery>,JQuery为开发插件增设了俩个方法: ...

  3. 关于table的td和ul元素li隔行变色的功能实现

    table元素的td和ul元素li隔行变色的功能实现 利用css控制二者的样式轻松实现隔行换色: 例如:table的css样式控制: table tr td{   background-color:颜 ...

  4. C# WPF DataGrid 隔行变色及内容居中对齐

    C# WPF DataGrid 隔行变色及内容居中对齐. dqzww NET学习0     先看效果: 前台XAML代码: <!--引入样式文件--> <Window.Resourc ...

  5. HTML系列:js和css多种方式实现隔行变色

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 案例(拖拽对话框、高清放大镜、自制滚动条、元素的隐藏方式、表格隔行变色、tab切换效果、字符串拼接、刷新评论)

    一.拖拽对话框 <style> .of{ width: 500px; } #link,#close{ text-decoration: none; margin: 0 10px; font ...

  7. JS实现表格隔行变色

    用到的鼠标事件:(1)鼠标经过 onmouseover:(2)鼠标离开 onmouseout 核心思路:鼠标经过 tr 行的时候,当前行会改变背景颜色,鼠标离开的时候去掉背景颜色. 注意:第一行(th ...

  8. jQuery知识点二 实现隔行变色

    <!DOCTYPE html> <html> <head> <meta name="viewport" content="wid ...

  9. css 隔行变色,表单布局

    隔行变色: #list1 li:nth-of-type(odd){ background:#00ccff;}奇数行  #list1 li:nth-of-type(even){ background:# ...

随机推荐

  1. 5.安装bacula-web(监控页面)

    1.   安装bacula-web(监控页面) 用途:监控bacula状态. http://docs.bacula-web.org/en/master/index.html bacula-web-7. ...

  2. redis cluster(集群)模式的创建方式

    redis常用的架构有三种,单例.哨兵.集群,其他的都说过了,这里只简单介绍集群搭建. 单例最简单没什么好说的. 哨兵之前说过,该模式下有哨兵节点监视master和slave,若master宕机可自动 ...

  3. github(工蜂)密码过期时sourcetree重新登录

  4. shell脚本中case /*的作用

    如下语句 case $0 in /*) ;; *) ;; /*在这里的作用就是绝对路径的意思

  5. linux异步传输支持

    基于libusbx-1.0.18-rc1,libusbx现已重新merage到libusb.1. 初始化使用libusb_init初始化libusb,如果是单设备通信,ctx参数可以传NULL,表示使 ...

  6. iOS的VideoToolBox与Android的MediaCodec对PTS的处理异同

    视频源,不论是从采集设备采集到的,还是本身压制好的文件,其流中的数据都是按照编码顺序存储的.比如1 2 3 4 5,5帧视频数据,1编码成I帧,2 3 4编码成B帧,5编码成P帧. 编码过程: 1. ...

  7. 在eclipse中xml文件注释的快捷键

    在eclipse中xml文件注释的快捷键 注释:Ctrl+Shift+/ 取消注释:Ctrl+Shift+\

  8. Zabbix trigger(触发器)设置

    设置一个监控项–进站包数,当进站包数>50触发器报警. 先设置一个进站包数的监控项(item):

  9. C语言之const

    鱼鹰  鱼鹰谈单片机 2月19日 预计阅读时间: 5 分钟 我们知道,数据分为两种,一种为只读,一种为可读可写,为了防止一些不变的数据被程序意外的修改,有必要对它进行保护.这就是 const 的作用. ...

  10. String字符串反转

    new StringBuffer("abcde").reverse().toString(); 通过char数组进行转换 package com.test.reverse; pub ...