Php smarty loop row and column

Source: Internet
Author: User
Tags php tutorial

Php Tutorial smarty loop row and column


Html example

<Div id = "result">
<! -- Rounded border -->
<Div style = "width: 750px; float: right;">
<Div style = "height: 1px; margin: 0 3px; background: # FF9900; overflow: hidden; font-

Size: 0px; "> </div>
<Div style = "height: 1px; margin: 0 1px; background: # FF9900; overflow: hidden; font-

Size: 0px; border-Left: 2px solid # FF9900; border-Right: 2px solid # FF9900; "> </div>
<Div style = "height: 1px; margin: 0 1px; background: # FF9900; overflow: hidden; font

-Size: 0px; border-Left: 2px solid # FF9900; border-Right: 2px solid # FF9900; padding

-Bottom: 0; "> </div>
<! -- Rounded border end -->
<Table width = "750" style = "border: 1px solid # ff9900;" align = "center"

Cellspacing = "0" cellpadding = "0">
<Tr>
<Td height = "20" align = "left" valign = "middle" bgcolor = "# ff9900"

Style = "color: # FFFFFF; font-weight: bold; padding-left: 20px; font-size: 14px ;"

Colspan = "3"> <a href = "#" class = "hot"> Latest product </a> </td>
</Tr>
<Tr>
{Foreach key = key item = item from = $ newarr}
{If $ key = 3} <tr >{/ if}
<Td height = "210" align = "center" valign = "middle">
<Table width = "210" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<Td width = "210" colspan = "2" align = "center" valign = "middle">

Src = "{$ item. pics}" width = "210" height = "180" style = "border: 1px solid # cccccc;

Padding: 0 10px; "onClick =" openshowcommo ({$ item. id}) "/> </td>
</Tr>
<Tr class = "mv">
<Td height = "17" align = "center" valign = "middle"> Market price: <font

Color = "# FF6600"> <B >{$ item. m_price }</B >¥ </font> </td>
<Td height = "17" align = "center" valign = "middle"> <font

Color = "# FF6600"> <B> member Price: {$ item. v_price} </B> $ </font> </td>
</Tr>
<Tr>
<Td height = "15" align = "center" valign = "middle">

Src = "images/777.png" alt =" consumer assurance service. The buyer promises to return goods without reason in 7 days "width =" 22"

Height = "20">

Width = "20" height = "21">

Width = "24" height = "16"> </td>
<Td height = "15" align = "center" valign = "middle"> <

Href = tencent: // message /? Uin = 718845039 & Site = www. cnclcy & Menu = yes>

Alt = "Click here to send me a message" src = "images/qq.png" width = "72" height = "25"> </a> </td>
</Tr>
</Table>
</Td>
{/Foreach}
</Tr>
<Tr>
<Td align = "center" colspan = "3" >{$ string} </td>
</Tr>
</Table>
</Div>
</Div>
Php code
<? Php
Include_once 'Conn/conn1.php ';
Include_once 'config. Php ';
$ Page1 = isset ($ _ GET ['page1 '])? $ _ GET ['page1 ']: 1;
$ Shownum = 6;
$ Start = $ shownum * ($ page1-1 );
$ Arr = selectArr ("*", "tb_commo", "where isnew = 1 order by isnew, id desc limit

$ Start, $ shownum ");
$ Num = number ("*", "tb_commo", "where isnew = 1 order by isnew, id desc ");
If ($ num = 0)
    {
Echo "in no record! ";
    }
Else
    {
$ Pagenum = ceil ($ num/$ shownum );
$ String = "";
For ($ I = 1; $ I <= $ pagenum; $ I ++)
        {
$ String. = ($ I = $ page1 )? "<Input type = 'buttom 'style = 'border: 1px

Solid # ff6600; text-align: center; width: 18px;

Height: 18px; background: # ffffcc; color: # ff6600; 'value = '$ I'> "." ":" <

Onclick = webpage effect: result ('allnew. php? Page1 = $ I ')> <B> "." <input type = 'buttom'

Style = 'border: 1px solid #669900; text-align: center; width: 18px;

Height: 18px; cursor: pointer 'value = '$ I'> "." </B> </a> ";
        }
    }
$ Smarty-> assign ('newarr', $ arr );
$ Smarty-> assign ('string', $ string );
$ Smarty-> assign ('title', 'latest item ');
$ Smarty-> display('allnew.html ');
  
?>

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.