首页 > 解决方案 > 回显脚本未启动

问题描述

我正在创建一个论坛。当我尝试回显对帖子的评论时,就会出现问题。该脚本似乎没有做任何事情。

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>
            ';    }
}
}
?>

我不明白这是怎么回事。我没有收到任何错误消息,也没有在网页上看到任何内容

标签: javascriptphphtmlsql

解决方案


推荐阅读