function list_sort($num,$sort)  {
echo "<table><tr>"
$query=mssql_query("select * from yszx where sort='$sort' order by id desc");
    $n=1;
while ($result=mssql_fetch_object($query)) {
    if (($i%$num)==0)
          {
            echo "</tr><tr>"
          }
echo "<td width=25%><div align=center>";
echo "<a href=show.php?film_name=".$result->film_name." target=_blank><img src=image/".$result->pic." width=120 height=145></a><p>
   <font size=2>".$result->film_name."</font></div></td>";
$n=$n+1;
     } 
echo "</tr></table>"
}

解决方案 »

  1.   

    厉害,
       还有一个小问题:见:http://www.yd.jxmu.edu.cn/newyd/yd/yszx/sort.php?sort=%C1%AC%D0%F8%BE%E7出现这种情况,出现背景色的地方没有<td>.当影片数不足一排时,怎么样可以补上剩下的<td></td>,才不致于显示出背景色来
      

  2.   

    function list_sort($num,$sort)  {
    echo "<table><tr>"
    $query=mssql_query("select * from yszx where sort='$sort' order by id desc");
        $n=1;
    while ($result=mssql_fetch_object($query)) {
        if (($n%$num)==0)
              {
                echo "</tr><tr>"
              }
    echo "<td width=25%><div align=center>";
    echo "<a href=show.php?film_name=".$result->film_name." target=_blank><img src=image/".$result->pic." width=120 height=145></a><p>
       <font size=2>".$result->film_name."</font></div></td>";
    $n=$n+1;
         } 
        $n=($n%$num);
        for(;$n<$num;$n++)
         {
             echo "<td>&nbsp;</td>"
          }
    echo "</tr></table>"
    }