<?php
echo '<table border="1">';
for($i=0;$i<10;$i++){
if($i%2==0) echo '<tr>';
echo '<td>'.$i.'</td>';
if($i%2==1) echo '</tr>';
}
echo '</table>';
?>

解决方案 »

  1.   

    $query_ncbookname = "select nclassid,nclass,anclassid from scshop_nclass where anclassid='$ncclassid' order by nclassidorder desc";
    $result_ncbookname = mysql_query($query_ncbookname) or die(mysql_error());
    $i=2;//这里改动
    while($arr_ncbookname = mysql_fetch_array($result_ncbookname))
    {
    $strbook .="<td width=\"50%\">·<a href=\"more_fenlei.php?nclassid=$arr_ncbookname[nclassid]&anclassid=$arr_ncbookname[anclassid]&btype=$btype&ptype=$arr_ncbookname[nclass]\">".$arr_ncbookname[nclass]."</a></td>";
    if($i%2 == 0)
    {
    echo "<table width=\"101%\" border=\"0\"><tr>$strbook</tr></table>";
    $strbook = "";
    }
    $i++;
    }试试!!
      

  2.   

    $i=0;
    $row = 2;
    $strbook = "<table width=\"101%\" border=\"0\">"; while($arr_ncbookname = mysql_fetch_array($result_ncbookname))
    {
    if ( $i == 0 )
    {
    $strbook .= "<tr>";
    }
    $strbook .="<td width=\"50%\">·<a href=\"more_fenlei.php?nclassid=$arr_ncbookname[nclassid]&anclassid=$arr_ncbookname[anclassid]&btype=$btype&ptype=$arr_ncbookname[nclass]\">".$arr_ncbookname[nclass]."</a></td>";
    if($i == $row-1)
    {
    $strbook .= "</tr>";
    $i = 0;
    }
    else
    $i++;
    }
    $str .= "</table>";
      

  3.   

    $query_ncbookname = "select nclassid,nclass,anclassid from scshop_nclass where anclassid='$ncclassid' order by nclassidorder desc";
    $result_ncbookname = mysql_query($query_ncbookname) or die(mysql_error());
    $i=0;
    while($arr_ncbookname = mysql_fetch_array($result_ncbookname))
    {
    $strbook ="<td width=\"50%\">·<a href=\"more_fenlei.php?nclassid=$arr_ncbookname[nclassid]&anclassid=$arr_ncbookname[anclassid]&btype=$btype&ptype=$arr_ncbookname[nclass]\">".$arr_ncbookname[nclass]."</a></td>";
    if($i%2 == 0) echo "<table width=\"101%\" border=\"0\"><tr>';
    echo $strbook;
    if($i%2==1) echo "</tr></table>";
    $i++;
    }
      

  4.   

    1、没有看出需求上的明显差异。难道就是把·经典译丛 从第一行移到最后一行?好象不是吧?
    2、你可能需要的是这样的格式
    ·经典译丛 ·影印教材 
    ·会计 ·经济学
    ·管理学 ·金融
    ·贸易 ·财政
    ·物流管理 ·项目管理
    ·营销管理 ·电子商务
    ·考试丛书 ·励志图书
    ·保险 
    如果是,可把$i++;放在if($i%2 == 0)前面。写成
    $i++;
    if($i%2 == 0) {
    echo "<table width=\"101%\" border=\"0\"><tr>$strbook</tr></table>";
    $strbook = "";
    }