行变色

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. 目标检测之RefineDet

    RefineDet 一.相关背景 中科院自动化所最新成果,CVPR 2018 <Single-Shot Refinement Neural Network for Object Detectio ...

  2. VTORRAAYY ws+tls+nginx config

    # nginx conf partal location /haha { proxy_redirect off; # the prot should same with config v2*** pr ...

  3. 02_Hive安装简介

    1.下载Hive安装包: 官网下载:http://hive.apache.org/downloads.html 百度云分享:https://pan.baidu.com/s/1M4LmdOXaq6T-P ...

  4. rdb和aof二种持久化方式对比(Redis)

    我们已经知道对于一个企业级的redis架构来说,持久化是不可减少的 企业级redis集群架构:海量数据.高并发.高可用 持久化主要是做灾难恢复,数据恢复,也可以归类到高可用的一个环节里面去 比如你re ...

  5. BIO、NIO、AIO 有什么区别?(未完成)

    BIO.NIO.AIO 有什么区别?(未完成)

  6. C# 委托、lambda表达式和事件 (7) 持续更新

    引用方法 在C++,函数指针只不过是一个指向内存位置的指针,它不是类型安全的. C# 委托 定义了返回类型和参数的类型.委托类包含对方法的引用,还可以包含多个方法引用. 定义委托 public del ...

  7. Codeforces Round #588 (Div. 2) C. Anadi and Domino(思维)

    链接: https://codeforces.com/contest/1230/problem/C 题意: Anadi has a set of dominoes. Every domino has ...

  8. SQL Server查询表结构语句

    --1:获取当前数据库中的所有用户表   www.2cto.com   select Name from sysobjects where xtype='u' and status>=0  -- ...

  9. django.core.exceptions.ImproperlyConfigured: The included URLconf 's9luffycity.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused

    出现问题: $ python manage.py runserver 启动项目报错时候 raise ImproperlyConfigured(msg.format(name=self.urlconf_ ...

  10. Python JSONⅢ

    JSON 函数 encode Python encode() 函数用于将 Python 对象编码成 JSON 字符串. 语法 实例 以下实例将数组编码为 JSON 格式数据: 以上代码执行结果为: d ...