利用Smarty实现文本隔行变色
行变色
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实现文本隔行变色的更多相关文章
- jquery实现html表格隔行变色
效果图 实现代码: 通过css控制样式,利用jquery的addClass方法实现 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Trans ...
- 我的第一个jQuery插件--表格隔行变色
虽然网上有大量的插件供我们去使用,但不一定有一款适合你的,必要的时候还是要自己动手去敲的.下面,开始我的第一个插件... 参考<锋利的JQuery>,JQuery为开发插件增设了俩个方法: ...
- 关于table的td和ul元素li隔行变色的功能实现
table元素的td和ul元素li隔行变色的功能实现 利用css控制二者的样式轻松实现隔行换色: 例如:table的css样式控制: table tr td{ background-color:颜 ...
- C# WPF DataGrid 隔行变色及内容居中对齐
C# WPF DataGrid 隔行变色及内容居中对齐. dqzww NET学习0 先看效果: 前台XAML代码: <!--引入样式文件--> <Window.Resourc ...
- HTML系列:js和css多种方式实现隔行变色
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 案例(拖拽对话框、高清放大镜、自制滚动条、元素的隐藏方式、表格隔行变色、tab切换效果、字符串拼接、刷新评论)
一.拖拽对话框 <style> .of{ width: 500px; } #link,#close{ text-decoration: none; margin: 0 10px; font ...
- JS实现表格隔行变色
用到的鼠标事件:(1)鼠标经过 onmouseover:(2)鼠标离开 onmouseout 核心思路:鼠标经过 tr 行的时候,当前行会改变背景颜色,鼠标离开的时候去掉背景颜色. 注意:第一行(th ...
- jQuery知识点二 实现隔行变色
<!DOCTYPE html> <html> <head> <meta name="viewport" content="wid ...
- css 隔行变色,表单布局
隔行变色: #list1 li:nth-of-type(odd){ background:#00ccff;}奇数行 #list1 li:nth-of-type(even){ background:# ...
随机推荐
- Packet for query is too large (4,544,730 > 4,194,304). You can change this value on the server by setting the 'max_allowed_packet' variable.
修改 my.ini 加上 max_allowed_packet =6710886467108864=64M默认大小4194304 也就是4M修改完成之后要重启mysql服务,如果通过命令行修改就不用 ...
- Django—logging配置
我写Django项目常用的logging配置. # Django的日志配置项 BASE_LOG_DIR = os.path.join(BASE_DIR, "log") LOGGIN ...
- Hadoop_31_MapReduce参数优化
1.资源相关参数 (1) mapreduce.map.memory.mb: 一个Map Task可使用的资源上限(单位:MB),默认为1024.如果Map Task实际使用 的资源量超过该值,则会被强 ...
- 09_Redis_消息订阅与发布
一:Redis 发布订阅 Redis 发布订阅(pub/sub)是一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息. Redis 客户端可以订阅任意数量的频道. 下图展示了频道 c ...
- centos7支持exfat
centos7支持exfat https://blog.csdn.net/shile/article/details/52202030 sudo rpm -Uvh http://li.nux.ro/d ...
- vue-cli3项目中使用CDN
1.html 中引入 echarts html中添加script标签如下: <script src="//cdn.bootcss.com/echarts ...
- appium连接Android真机,并调试
Android真机:华为pad2 Android和Windows连接同一个局域网 连接USB Android机设置: 打开USB调试 cmd>adb devices,显示Android序列号 , ...
- formData+ajax文件上传
html代码: <form class="form-horizontal" enctype="multipart/form-data" method=&q ...
- BZOJ 1188 / Luogu P3185 [HNOI2007]分裂游戏 (SG函数)
题意 有n个格子,标号为0 ~ n-1,每个格子上有若干石子,每次操作可以选一个0 ~ n-2的格子上的一颗石子,分裂为两颗,然后任意放在后面的两个格子内,这两个格子可以相同.求使先手必胜的第一步的方 ...
- Git始终忽略特定文件的某一行内容
笔者在编写Z Shell文件的时候经常会使用到set -x来开启调试,但不希望提交到仓库 解决方案 Git提供了一种文件过滤器,此方法可以帮助在提交时移除set -x 我们先来编写脚本,如何移除这一行 ...