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

PHP
第十三节--对象串行化 -- Classes and Objects in PHP5 [13]
第十一节--重载 -- Classes and Objects in PHP5 [11]
第十节--抽象方法和抽象类 -- Classes and Objects in PHP5 [10]
第九节--绑定 -- Classes and Objects in PHP5 [9]
第八节--访问方式 -- Classes and Objects in PHP5 [8]
第七节--类的静态成员 -- Classes and Objects in PHP5 [7]
第六节--访问属性和方法 -- Classes and Objects in PHP5 [6]
第五节--克隆 -- Classes and Objects in PHP5 [5]
第四节--构造函数和析构函数 -- Classes and Objects in PHP5 [4
第三节--定义一个类 -- Classes and Objects in PHP5 [3]
第二节--PHP5 的对象模型 -- Classes and Objects in PHP5 [2]
第一节--面向对象编程 -- Classes and Objects in PHP5 [1]
初探 PHP5 (二)
初探 PHP5 (一)
SSI使用详解(二)
SSI使用详解(一)
Cookie及其使用(二)
Cookie及其使用(一)
实现跨域名Cookie
两种统计当前在线人数的方法

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 66 ::
收藏到网摘: 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>