从数据库中获取5张图片,显示3张后换行显示,结果却为3行显示,第一行为2张图片!
源代码如下:
newhot1.php:
<?php
include_once 'conn/conn.php';
include_once 'config.php';
$newsql = "select id,name,pics,m_price,v_price from tb_commo where isnew = 1 order by id desc";
$nm = 5;
$newrst = $conn->SelectLimit($newsql,$nm);

$newarr = $newrst->GetArray();

$smarty->assign('newarr',$newarr);
$smarty->display('newhot1.tpl');
?>newhotq.tpl:
<link rel="stylesheet" href="css/newhot.css" />
<link href="css/top.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="js/showcommo.js"></script>
<table id="__01" width="450" height="380" border="0" cellpadding="0" cellspacing="0">
<tr>

<td width="295" height="307" align="left" valign="top" >
<table width="295" height="307" align="center" border="0" cellpadding="0" cellspacing="0">
         <tr>
        {foreach key=nkey item=nitem from=$newarr}
         <td align="left" valign="top" >
             <table width="147" height="150" align="left" border="0" cellpadding="0" cellspacing="0">
                 <tr>
                     <td height="100" align="center" valign="middle"><img src="{$nitem.pics}" width="100" height="80" alt="{$nitem.name}"></td>
                    </tr>
              
      
              </table>            </td>
           {if $nkey mod 3 != 0}           
   </tr><tr>
           {/if}
        {/foreach}
         </tr>
        </table>        </td>
</tr>

</table>