-1

我有一个这样的while语句:

while ($row= mysql_fetch_assoc($sql)){      

  $comments .= "<fieldset> User Says : <div class='each_comment'>  <small><em> ".convert($row['comment_date'])." </em></small><br />".$row['comment']." 

  <input type='text' class='reply' comments_id='{$row['comments_id']}' />

      </div></fieldset>  </br>"; 
}

我要做的就是插入这一行:

 $reply_query = mysql_query("SELECT reply_id, reply FROM comments_reply WHERE comments_id='$comments_id' ");  

高于输入和低于 $comments。问题是我尝试过的任何事情都会导致我出错。到目前为止,我是这样做的:

while ($row= mysql_fetch_assoc($sql)){      

  $comments .= "<fieldset> User Says : <div class='each_comment'>  <small><em> ".convert($row['comment_date'])." </em></small><br />".$row['comment']." 

      $reply_query = mysql_query("SELECT reply_id, reply FROM comments_reply WHERE comments_id='$comments_id' ");

  <input type='text' class='reply' comments_id='{$row['comments_id']}' />

      </div></fieldset>  </br>"; 
}

可以在那里使用吗?知道如何解决这个问题吗?

4

1 回答 1

0
while ($row= mysql_fetch_assoc($sql)) {
    $comments .= "<fieldset> User Says : <div class='each_comment'>  <small><em> ".convert($row['comment_date'])." </em></small><br />".$row['comment'];
    $reply_query = mysql_query("SELECT reply_id, reply FROM comments_reply WHERE comments_id='$comments_id' ");
    while ($row2= mysql_fetch_assoc($reply_query)) {
        // do what you want with the reply results
    }
    $comments .= "<input type='text' class='reply' comments_id='{$row['comments_id']}' />
    </div></fieldset>  </br>"; 
}
于 2013-08-11T10:57:02.340 回答