一行显示多列的问题
我现在控制的是一行显示4条记录,但问题是如果正好是4条记录则能正常显示,但超出4条或小于4条的其他记录是显示不出来的,请各位大虾看看语句哪里错了?
代码如下:
$i=0;
$im=$na=$pl="";
while(list($theads1,$theads,$kid1,$key)=each($photothread)){
if($theads[path_s]==""){
$theads[path_s]=$theads[path];
}
$photo=$config[upload].$theads[path_s];
if($i==0){
$im.="<tr>";
$na.="<tr>";
$pl.="<tr>";
}
$im.="<td class=\"tupianpic\"><a href=\"/starlive/".$theads[singer_id]."/showphoto/".$theads[id]."\" target=\"_blank\"><img style=\"max-width: 110px; width:expression(this.width > 110 ? '110' : this.width);\" src=\"".$photo."\" /></a></td>";
$na.="<td>位置:<a href=\"/starlive/".$theads[singer_id]."\" target=\"_blank\">".$theads[cn_name]."</a></td>";
$sql="select count(pid) from bbs_posts where tid in (select tid from bbs_threads where topic_id=$theads[id]) and first<>1";
$result=$db->query($sql);
list($pinlun)=$db->fetchRow($result);
$pl.="<td>评论数:".$pinlun."</td>";
$i++;
if($i>3){
$im.="</tr>";
$na.="</tr>";
$pl.="</tr>";
echo "$im$na$pl";
$i=0;
$im=$na=$pl="";
}