当前位置: 首页 > 图文教程 > 网络编程 > PHP > php横向重复区域显示二法

PHP
PHP新手总结的PHP基础知识
php实现gb2312和unicode间编码转换
用php语言实现数据库连接详细代码介绍
详细解析 PHP 向 MySQL 发送数据过程
利用PHP V5开发多任务应用程序
详细讲解PHP中缓存技术的应用
php escapeshellcmd多字节编码漏洞
《PHP设计模式介绍》导言
《PHP设计模式介绍》第一章 编程惯用法
《PHP设计模式介绍》第二章 值对象模式
《PHP设计模式介绍》第三章 工厂模式
《PHP设计模式介绍》第四章 单件模式
《PHP设计模式介绍》第五章 注册模式
《PHP设计模式介绍》第六章 伪对象模式
《PHP设计模式介绍》第七章 策略模式
《PHP设计模式介绍》第八章 迭代器模式
《PHP设计模式介绍》第九章 观测模式
《PHP设计模式介绍》第十章 规范模式
《PHP设计模式介绍》第十一章 代理模式
《PHP设计模式介绍》第十二章 装饰器模式

PHP 中的 php横向重复区域显示二法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 224 ::
收藏到网摘: n/a

图片横向重复显示的实现方法 方法一. 注意这里有一个预先定义的图片记录集rsmpic 要横向重复的就是图片,请根据你的情况改为你的记录集名称.整齐地将横向重复内容放在一个表格内
<table width="100" border="0" align="center" cellpadding="5" cellspacing="5">
<?PHP $startrw = '0';// 开始定义横向重复内容 这里设定为 3 行 3 列 $endrw = $HLooper1__index;
$numberColumns = '3';
$numrows = '3';
while(($numrows <> 0) AND (!$rsmpic->EOF))
{
$startrw = $endrw + 1;
$endrw = $endrw + $numberColumns;?>
<tr>
<?PHP While (($startrw <= $endrw) AND (!$rsmpic->EOF)) { //开始重复内容?>
<td>
<table width="78%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="../<?PHP echo $rsmpic->Fields('M_Path'); ?>" border="0"></td>
</tr>
</table>
</td>
<?PHP
$startrw = $startrw + 1;
$rsmpic->MoveNext();}//以上重复td内容 ?>
</tr>
<?PHP $numrows=$numrows-1;
Wend; }
方法二. 将重复标记拖到<td>外(纵向重复是在<tr>外),加入一个变量, 每重复 1 次加 1, 如果%3等于0 echo 一个"<tr>" . 请仔细看
<table width="100%" border="1" cellspacing="1" cellpadding="5">
<tr>
<?PHP $str=0;// 开始定义重复函数?>
<?PHP do { //开始重复?>
<td>
<?PHP $str++;?>
<?PHP echo $str; ?>.<?PHP echo $row_Recordset1['NAME']; ?>
</td>
<?PHP if ($str%3==0)echo "<tr>"; ?>
<?PHP } while ($row_Recordset1 = MySQL_fetch_assoc($Recordset1)); // 重复td内容?>
</tr>
</table>