2011-07-23 21 views
0

投稿するユーザーのコメントページを作成しました。他のユーザーが投稿した投稿にコメントすることはできますが、問題は1つありますが、簡単ですが、投稿のユーザーコメントは正常に表示されますが、3または5などがある場合はコメントが表示されないので、最後に投稿コメントが表示されることを非常に明確にすることができますその上の他のコメントです。私は、完全なアイデアを与えるためにコメントは最後の投稿の後にのみ表示されます

を全体のコードを入力しているとコメントが表示されるのコードは責任がある、これは私のコード

<?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>&nbsp;</td> 
    >      <td colspan="4" class="blogBBg"><?php echo 
    > $blog->Bdescription; ?></td> 
    >     </tr> 
    >     <tr> 
    >      <td>&nbsp;</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">&nbsp;</td> 
    >         <td width="197"><?php echo 
    > $dig->comments; ?></td> 
    >        </tr> 
    >        </table> 
    >        
    >        
    >      <?php 
    >      
    >      } 
    >    
    >    } ?> 
    > 
    > </div> 

ある

それを表示されません、このです。皆のための

$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">&nbsp;</td> 
           <td width="197"><?php echo 
$dig->comments; ?></td> 
           </tr> 
          </table> 


         <?php 

         } 

       } ?> 

答えて

0

おかげで、私はそれを持って、私が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">&nbsp;</td> 
           <td width="197"><?php echo $dig->comments; ?></td> 
           </tr> 
          </table> 


         <?php 

         } 

       } 
?> 

として、このコードを配置し、その後、私は含まI側のような非常に簡単でしたメインのブログページにあり、今はとてもうまく動いています。

ありがとう、もう一度皆さん、

関連する問題