如何在php while循环中的特定div中追加数据
我有一个评论系统,其中我附加了用户所做的评论,但是当我附加数据时,它来了: [object HTMLCollection]: [object HTMLCollection]
我也想知道如何在用户评论的特定post上附加此评论。
我的PHP代码:
$query = "SELECT ph.ext, ph.likes,ph.desccription, ph.image_url,ph.email,ph.username,ph.uid ,ph.id,ph.avatar_path FROM photos as ph inner join followers as fol on fol.user_id = ph.uid where fol.uid = '$id' ORDER BY ph.image_url DESC limit 5"; $fire = mysqli_query($con,$query) or die("can not fetch data from database ".mysqli_error($con)); if (mysqli_num_rows($fire)>0) { while ($users = mysqli_fetch_assoc($fire)) { $likes = $users['likes']; $description = $users['desccription']; $username = $users['username']; $uid = $users['uid']; $pixid = $users['id']; $avatar_path5 = $users['avatar_path']; ?> <img src="https://stackoverflow.com/questions/52889526/how-to-append-data-in-a-specific-div-in-a-php-while-loop/" width="100%" class="avatar"> <?php echo "
"; ?> <img src="https://stackoverflow.com/questions/52889526/how-to-append-data-in-a-specific-div-in-a-php-while-loop/" alt="Avatar" style="width:100%;"> <div id="comments" class="comments" data-post-id=""> 0) { while ($row = mysqli_fetch_assoc($results)) { $commentid = $row['id']; $comment = $row['comment']; $string = covertHashtags($comment); echo ""; echo "".$row['username'].""; echo " ".$string; $sql3 = "SELECT * FROM comment where id ='$commentid' and user_id='$id' order by comment desc limit 5 "; $results3 = mysqli_query($con,$sql3); if (mysqli_num_rows($results3)>0) { echo "
delete
"; } else{ echo ""; } echo ""; } }else{ echo ""; } ?>