php 查询记录集的 while嵌套问题

lanmaokyle 2008-06-17 06:24:38
我在一次查询中用到了while的循环嵌套,但是结果只显示外循环的记录集,内循环没有执行。
请教高手帮忙解决下。
代码如下:

<?php
$query_rs_table = "SELECT pubNewID,title, COUNT(*) AS num FROM comNewsTopubnews_VIEW where isread is null GROUP BY pubNewID,title ORDER BY pubnewid DESC";
$rs_table=mssql_query($query_rs_table);
$rowcount = mssql_num_rows($rs_table);
normalize($page,$rowcount);
if($rowcount)
mssql_data_seek($rs_table,($page-1)*$display_num);

// echo $query_rs_table;
while($row=mssql_fetch_array($rs_table))
{
$pubNewID = $row['pubNewID'];
$newstitle = $row['title'];
?>
<tr align="center" class="forumRow">
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="3" >

<tr>
<td width="10%" align="right">标题:</td>
<td colspan="3" align="left"><span style="color:#0066FF "><?php echo $newstitle==""?"该条新闻资讯已被删除":$newstitle;?></span></td>
<td align="left">[<a href="ComNews.php?hotNewsID=<?=$row['pubNewID'];?>">查看本文所有评论</a>]</td>
<td width="20%" align="left">[<a href="ComNews.php?action=delAll&NewsID=<?=$row['pubNewID'];?>">删除本文所有评论</a>]</td>
</tr>
<?php
$sql_comNews_pubNewID = "SELECT TOP 30 *
FROM comNews
WHERE (pubNewID = '$pubNewID')
ORDER BY IsRead, comTime DESC";
$query_comNews_pubNewID = mssql_query($query_comNews_pubNewID);
$display_num1=20;
$seq=0;
//echo $sql_comNews_pubNewID;
while($row_comNews_pubNewID = mssql_fetch_array($query_comNews_pubNewID)){
if($seq++==$display_num1) break;

?>
<tr>
<td align="right"><input name='lyID[]' type='checkbox' onClick="unselectall()" id="lyID[]" value="<?=$row_comNews_pubNewID['ID'];?>"><?php echo ($page-1)*$display_num1+$seq; ?></td>
<td width="40%"><?=$row_comNews_pubNewID['comText'];?></td>
<td width="10%"><?=$row_comNews_pubNewID['comUserNickName'];?></td>
<td width="10%"><?=$row_comNews_pubNewID['comUserLoginName'];?></td>
<td width="15%"><?=convert($row_comNews_pubNewID['comTime']);?></td>
<td>[<?php if($row_comNews_pubNewID['IsRead'] == 1){echo "<font color='#FF0000'>已查阅</font>";}else{?><a href="ComNews.php?read=one&action=readed&id=<?=$row_comNews_pubNewID['ID'];?>&state=<?=$isread;?>">查阅</a><?php }?>]
[<a href="javascript:onclick=Modify(<?=$row_comNews_pubNewID['ID'];?>);">修改</a>]
[<a href="ComNews.php?del=one&action=delly&id=<?=$row_comNews_pubNewID['ID'];?>&state=<?=$isread;?>" onClick="{if(confirm('确定要删除此评论吗?一旦删除将不能恢复?')){return true;}return false;}">删除</a>]</td>
</tr>
<?php }?>
<tr align="center">
<td colspan="6"> </td>
</tr>
</table>
<hr size="1" class="hr"></td>
</tr>
<?php
}
mssql_free_result($rs_table);
?>
...全文
50 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
qianziai0912 2008-06-18
  • 打赏
  • 举报
回复
mssql_fetch_array()?
好像是mysql_fetch_array()吧
这个函数只显示1条数据,
需要打印全部数据请用 函数mysql_num_rows()
在用for()可以全部打印出来

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧