Php 评论只出现在最后一篇文章之后
我为用户制作了一个评论页面,其他人可以对他们的帖子发表评论。它运行得很好,但有一个问题我认为很容易,但我无法得到它,当用户在帖子“一”上发表评论时,它会正常出现,但当出现3或5条评论时,等等。评论一不会像它不在那里一样出现,因此最后我可以非常清楚地表明,最后一条帖子评论会出现,但如果顶部有任何其他评论。它没有出现 这是我的密码Php 评论只出现在最后一篇文章之后,php,mysqli,Php,Mysqli,我为用户制作了一个评论页面,其他人可以对他们的帖子发表评论。它运行得很好,但有一个问题我认为很容易,但我无法得到它,当用户在帖子“一”上发表评论时,它会正常出现,但当出现3或5条评论时,等等。评论一不会像它不在那里一样出现,因此最后我可以非常清楚地表明,最后一条帖子评论会出现,但如果顶部有任何其他评论。它没有出现 这是我的密码 <?php > > $getBlogs = "select * from blogs wher
<?php
>
> $getBlogs = "select * from blogs where active = 1";
> $blogResults = $db -> query ($getBlogs) or die ($db->error); if
> ($blogResults) {
> while ($blog = $blogResults -> fetch_object()) {
>
> ?>
>
>
>
> <table width="600" border="0" cellpadding="0"
> cellspacing="0">
> <tr class="bons">
> <td width="62" align="right" valign="middle"
> class="blogIBg"><img src="images/blog.png" width="37" height="30"
> /></td>
> <td width="243" height="28" class="blogSBg"><?php
> echo $blog->Btitle; ?></td>
> <td width="78" height="28" class="blogSBg"><span
> class="by11">Posted by :</span></td>
> <td width="117" height="28" class="blogSBg"><span
> class="blogby12Bg"><span class="red"><b><?php echo $blog->ByName;
> ?></b></span></span></td>
> <td width="100" class="blogSBg"><span
> class="by11"><?php echo $blog->dateAdded ?></span></td>
> </tr>
> <tr>
> <td> </td>
> <td colspan="4" class="blogBBg"><?php echo
> $blog->Bdescription; ?></td>
> </tr>
> <tr>
> <td> </td>
> <td colspan="4" align="right" bgcolor="#D5F1FF"
> class="blogby11Bg"><a class='example7'
> href="includes/postComments.php?id=<?php $gotIT=$blog->id; echo
> $gotIT; ?>">Comment</a></td>
> </tr>
> </table>
> <br />
> <?php
>
> } }
> $comments = "select * from blogscomments where blogestID =
> $gotIT"; $resultComments = $db -> query ($comments) or die
> ($db->error);
> if ($resultComments) {
>
>
> while ($dig = $resultComments -> fetch_object()) {
> ?>
>
> <table width="500" border="0">
> <tr>
> <td width="32"> </td>
> <td width="197"><?php echo
> $dig->comments; ?></td>
> </tr>
> </table>
>
>
> <?php
>
> }
>
> } ?>
>
> </div>
>
>
>
>cellspacing=“0”>
>
>class=“blogIBg”>/>
>
>class=“by11”>发布人:
>class=“blogby12Bg”>
>class=“by11”>
>
>
>
>
>
>
>
>class=“blogby11Bg”>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
我已经输入了整个代码来给出一个完整的想法
而代码负责出现的注释就是这样
$comments = "select * from blogscomments where blogestID =
$gotIT"; $resultComments = $db -> query ($comments) or die
($db->error);
if ($resultComments) {
while ($dig = $resultComments -> fetch_object()) {
?>
<table width="500" border="0">
<tr>
<td width="32"> </td>
<td width="197"><?php echo
$dig->comments; ?></td>
</tr>
</table>
<?php
}
} ?>
$comments=“从blogscomments中选择*blogestID=
$gotIT”$resultComments=$db->query($comments)或die
($db->错误);
如果($resultComments){
而($dig=$resultComments->fetch_object()){
?>
谢谢大家,我刚刚得到了它,非常简单,我创建了一个名为handlingComments.php的单独php文件,并将此代码按原样放置
<?php
$comments = "select * from blogscomments where blogestID = $gotIT";
$resultComments = $db -> query ($comments) or die ($db->error);
if ($resultComments) {
while ($dig = $resultComments -> fetch_object()) {
?>
<table width="500" border="0">
<tr>
<td width="32"> </td>
<td width="197"><?php echo $dig->comments; ?></td>
</tr>
</table>
<?php
}
}
?>
然后我把它放在了博客主页上,现在运行得很好
再次感谢大家,