php 查询记录集的 while嵌套问题
我在一次查询中用到了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);
?>