


Two ways to display horizontal repeating areas in php_PHP tutorial
Jul 21, 2016 pm 03:49 PM
Method 1. Note that there is a predefined picture record set rsmpic. The pictures to be repeated horizontally are pictures. Please change the name of your record set according to your situation. Neatly put the horizontally repeated content in a table
< table width="100" border="0" align="center" cellpadding="5" cellspacing="5">
<?PHP $startrw = '0';// Start defining horizontal repeating content here Set to 3 rows and 3 columns $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)) { //Start repeating content?>
<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();}//The above repeats td content?>
</tr>
<?PHP $numrows=$numrows-1;
Wend; }
Method 2. Drag the repeat mark outside the <td> (vertical repetition is outside the <tr>), and add a variable, Add 1 for each repetition, if %3 is equal to 0 echo a "<tr>" . Please look carefully
<table width="100%" border="1" cellspacing="1" cellpadding="5 ">
<tr>
<?PHP $str=0;//Start defining a repeating function?>
<?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($ Recordset1)); // Repeat td content?>
</tr>
</table>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
