fix nested replies
This commit is contained in:
parent
22756c834e
commit
487ad1e376
1 changed files with 20 additions and 7 deletions
|
@ -37,11 +37,20 @@
|
|||
</div>
|
||||
|
||||
<?php
|
||||
$posts = array();
|
||||
|
||||
$theId = $idr;
|
||||
|
||||
while (true) {
|
||||
$stmt = $db->prepare("SELECT * FROM comment WHERE id = ? ORDER BY date DESC");
|
||||
$stmt->execute([
|
||||
$idr
|
||||
$theId
|
||||
]);
|
||||
$posts1 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
if (is_null($posts1) || count($posts1) < 1) break;
|
||||
$theId = $posts1[0]['targetid'];
|
||||
$posts = array_merge($posts1,$posts);
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM comment WHERE targetType = ? AND targetId = ? ORDER BY date DESC LIMIT ? OFFSET ?");
|
||||
$stmt->execute([
|
||||
|
@ -53,9 +62,13 @@
|
|||
|
||||
$posts2 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
|
||||
$posts = array_merge($posts1,$posts2);
|
||||
$edge = count($posts);
|
||||
$posts = array_merge($posts,$posts2);
|
||||
|
||||
foreach ($posts as $post) { ?>
|
||||
foreach ($posts as $key => $post) {
|
||||
if ($key == $edge) { ?>
|
||||
<h2>Replies</h2>
|
||||
<?php } ?>
|
||||
<div class='comment'>
|
||||
<div class='avatar'>
|
||||
<img src='/pfp/<?php echo $post['username'] ?>.png' class='avatar-img'>
|
||||
|
|
Loading…
Reference in a new issue