我正在创建一个论坛。当我尝试回显帖子上的评论时,会发生问题。该脚本似乎没有任何作用。
if($result->num_rows>0){
while($row = $result->fetch_assoc()){
$username=$row['username'];
$file=$row['file'];
$text=$row['text'];
$date=$row['date'];
$postId=$row['postId'];
$commentOn=$row['commentOn'];
if($commentOn == 0){
echo'
<li>
<div class="comment">
<p><am>+</am>'.$username.'</a><em>'.$date.'</em> _ #'.$postId.'</p>
<div>
<img src='.$file.'>
<p>'.$text.'</p>
<p><Button>upvote</Button><Button>downvote</Button><form action="upload2.php" method="post" enctype="multipart/form-data" accept-charset="utf-8">
<textarea name="text" cols="30" rows="2"></textarea>
<textarea id="sov" name="postIdr">'.$postId.'</textarea>
<input type="submit" value="Reply">
</form><ap>Reply</ap></p>
</div>
</div>
<div id="h'.$postId.'"></div>
</li>';
}else{
//Here is where the problem area starts
echo' <script type="text/javascript"> document.getElementById("h'.$commentOn.'").innerHTML = "
<ul>
<li>
<div class="comment">
<p><am>+</am>'.$username.'</a><em>'.$date.'</em> _ #'.$postId.'</p>
<div>
<p>'.$text.'</p>
<p><Button>upvote</Button><Button>downvote</Button><form action="upload2.php" method="post" enctype="multipart/form-data" accept-charset="utf-8">
<textarea name="text" cols="30" rows="2"></textarea>
<textarea id="sov" name="postIdr">'.$postId.'</textarea>
<input type="submit" value="Reply">
</form><ap>Reply</ap></p>
</div>
</div>
<div id="h'.$postId.'"></div>
</li>
</ul>
";</script>
'; }
}
}
?>
我看不出这是怎么回事。我没有收到任何错误消息,并且在网页上什么也看不到