问个显示的问题. 可以定义一个变量,初始值为1。然后在循环的时候不要写在<tr></tr>之间,而是<tr></td>之间,然后循环后面把变量+1,最后判断是否等于4,如果是就echo一个</tr>.思想就是这样,相信你行的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <? $exec="select * from pic_img where sortid='$rssort->id' order by id desc";//求总的记录数 $result=mysql_query($exec); $recountCount = mysql_num_rows($result); $totalPage = ceil($recountCount/40); $page = (isset($page) && $page>=0)? $page: 0; $isLast = ($page==($totalPage-1))? true: false; $hasNoPre = ($page==0)? true: false; $hasNoNext = ($page==$totalPage-1)? true: false; $isFirst = ($page==0)? true:false; $exec="select * from pic_img where sortid='$rssort->id' order by id desc limit ".($page*40).",40";//一页是40记录的 $result=mysql_query($exec); $count=mysql_num_rows($result); $col=4; $row=floor($count/$col); $eol=$count%$col; if($eol>0) $row++; for($i=0; $i<$row; $i++) { echo "<tr>"; for($j=0; $j<$col; $j++) { $rslist=mysql_fetch_object($result); if($rslist==false) echo ""; else { ?> <TD> <TABLE cellSpacing=1 cellPadding=5 width=128 bgColor=#cecece border=0> <TBODY> <TR> <TD align=middle bgColor=#ffffff> <a href="view.php?pid=<? echo "$rslist->id"; ?>" target="_blank"><IMG src="<? echo "$siteurl$imgpath$rslist->imgsmall"; ?>" height=90 width=120 border=0></a><BR> <TABLE cellSpacing=0 cellPadding=5 width="100%" border=0> <TBODY> <TR> <TD align=middle height=42><? echo "$rslist->imgname"; ?></TD> </TR> </TBODY> </TABLE > </TD> </TR> </TBODY> </TABLE> </TD><? } } echo "</tr>"; } ?> <TR> <TD colspan="4"> <TABLE cellSpacing=1 cellPadding=5 width=100% align="center" bgColor=#cecece border=0> <TBODY> <TR> <TD align=right bgColor=#ffffff><? $str = "共 $recountCount 条,当前 ".($page+1)."/$totalPage 页 "; $str .= $isFirst? "首页 " : "<a href=\"sort.php?oid=$oid&page=0\">首页</a> "; $str .= $hasNoPre? "上页 " : "<a href=\"sort.php?oid=$oid&page=".($page-1)."\">上页</a> "; $str .= $hasNoNext? "下页 " : "<a name=\"morelist\" href=\"sort.php?oid=$oid&page=".($page+1)."\">下页</a> "; $str .= $isLast? "尾页 " : "<a href=\"sort.php?oid=$oid&page=".($totalPage-1)."\">尾页</a>"; echo $str;?> php取xml中的内容,在线等 哪里有下中国市,区,县的数据库 浏览器=》链结 有比这个更好的php最快捷的开发方式吗? 这个用php咋写啊,怎么写都错 请问怎么用变量表示变量? 本人的论坛由dvbbs8.2升级到phpwind8.7后,不能发视频flash了? linux下如何配置php支持PostgreSQL数据库连接? 生成首页失败 奇怪的 PHP 语句,求解惑。 假如这是网页的顶部,是在一副图画里,怎样激活他(怎样让他能够点击连接)? 请问有什么方法可以不 recompile php 而让它支持iconv模块呢?
$result=mysql_query($exec); $recountCount = mysql_num_rows($result);
$totalPage = ceil($recountCount/40);
$page = (isset($page) && $page>=0)? $page: 0;
$isLast = ($page==($totalPage-1))? true: false;
$hasNoPre = ($page==0)? true: false;
$hasNoNext = ($page==$totalPage-1)? true: false;
$isFirst = ($page==0)? true:false; $exec="select * from pic_img where sortid='$rssort->id' order by id desc limit ".($page*40).",40";//一页是40记录的
$result=mysql_query($exec);
$count=mysql_num_rows($result);
$col=4;
$row=floor($count/$col);
$eol=$count%$col;
if($eol>0)
$row++;
for($i=0; $i<$row; $i++)
{
echo "<tr>";
for($j=0; $j<$col; $j++)
{
$rslist=mysql_fetch_object($result);
if($rslist==false)
echo "";
else {
?>
<TD>
<TABLE cellSpacing=1 cellPadding=5 width=128 bgColor=#cecece border=0>
<TBODY>
<TR>
<TD align=middle bgColor=#ffffff>
<a href="view.php?pid=<? echo "$rslist->id"; ?>" target="_blank"><IMG src="<? echo "$siteurl$imgpath$rslist->imgsmall"; ?>" height=90 width=120 border=0></a><BR>
<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
<TBODY>
<TR>
<TD align=middle height=42><? echo "$rslist->imgname"; ?></TD>
</TR>
</TBODY>
</TABLE >
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
<?
} }
echo "</tr>";
}
?>
<TR>
<TD colspan="4">
<TABLE cellSpacing=1 cellPadding=5 width=100% align="center" bgColor=#cecece border=0>
<TBODY>
<TR>
<TD align=right bgColor=#ffffff>
<?
$str = "共 $recountCount 条,当前 ".($page+1)."/$totalPage 页 ";
$str .= $isFirst? "首页 " : "<a href=\"sort.php?oid=$oid&page=0\">首页</a> ";
$str .= $hasNoPre? "上页 " : "<a href=\"sort.php?oid=$oid&page=".($page-1)."\">上页</a> ";
$str .= $hasNoNext? "下页 " : "<a name=\"morelist\" href=\"sort.php?oid=$oid&page=".($page+1)."\">下页</a> ";
$str .= $isLast? "尾页 " : "<a href=\"sort.php?oid=$oid&page=".($totalPage-1)."\">尾页</a>";
echo $str;
?>