PHP Horizontal Repeat Region display two method _php skill

Source: Internet
Author: User
Method one. Note that there is a pre-defined picture recordset rsmpic the picture is to be duplicated horizontally, please change to your recordset name according to your situation. Neatly place horizontal duplicates in a table
<table width= "border=" 0 "align=" center "cellpadding=" 5 "cellspacing=" 5 ">
? PHP $startrw = ' 0 '//begin to define the horizontal repeat content is set to 3 rows 3 columns $ENDRW = $HLooper 1__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)) {//Start repeating content?>
<td>
<table width= "78%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
<td>fields (' M_path ');?> "border=" 0 "></td>
</tr>
</table>
</td>
? Php
$STARTRW = $startrw + 1;
$rsmpic->movenext ();} Above duplicate TD content?>
</tr>
? PHP $numrows = $numrows-1;
Wend; }
Method Two. Drag the repeating tag to <td> outside (vertical repeat is outside <tr>), add a variable, add 1 for each repeat 1 times if%3 equals 0 echo for a "<tr>". Please look carefully.
<table width= "100%" border= "1" cellspacing= "1" cellpadding= "5" >
<tr>
? PHP $str =0;//to start defining duplicate functions?>
? PHP do {//start repeating?>
<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 ($Recordset 1)); Repeat TD content?>
</tr>
</table>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.