0

我正在创建一个评论系统,用户可以在其中回答现有评论,但我想知道如何在现有评论(“父”评论)下缩进这些回复(“子”评论)。

这里是当前代码:

<h2>Fiche</h2>

<?php

$_SESSION['cf']['message'] = $_GET['message'];

$reponse = db_query('SELECT * FROM messages WHERE id = ?', array($_SESSION['cf']['message']));
$donneesmsg = $reponse->fetch()

?>


<h5><?php echo $donneesmsg['Pseudo']; ?></h5>

<p class="text-center text-align"><?php echo $donneesmsg['Message']; ?></p>

<a href="index.php?page=fiche&message=<?php echo $_SESSION['cf']['message'] ?>&#formcom">Repondre</a>

<?php

    echo '<h4>Commentaires</h4>';
    echo '<hr>';

            $reponse1 = db_query('SELECT * FROM comment WHERE messages_id = ?', array($donneesmsg['id']));
            $donneescom1 = $reponse1->fetch();

$reponse = db_query('SELECT * FROM comment WHERE messages_id = ? ORDER BY id ASC', array($donneesmsg['id']));
while ($donneescom = $reponse->fetch()) {


    if ($donneescom['commentaires_id'] == 0) 

        {

            echo '<center>';
            echo '' .$donneescom['id']. '<br>';
            echo '' .$donneescom['pseudo']. '<br>';
            echo '' .$donneescom['commentaire']. '<br>';
            echo '<a href="index.php?page=fiche&message=' .$_SESSION['cf']['message']. '&com=' .$donneescom['id']. '#formcom">Repondre</a>';
            echo '<hr>';
            echo '</center>';


        }


    if ($donneescom['commentaires_id'] != 0)
        {

            echo 'En reponse au com ' .$donneescom['commentaires_id']. '<br>';
            echo '' .$donneescom['id']. '<br>';
            echo '' .$donneescom['pseudo']. '<br>';
            echo '' .$donneescom['commentaire']. '<br>';
            echo '<a href="index.php?page=fiche&message=' .$_SESSION['cf']['message']. '&com=' .$donneescom['id']. '#formcom">Repondre</a>';
            echo '<hr>';



        }
    }

?>


<form id="formcom" method="post" action="index.php?page=addcomment">
Pseudo: <input type="text" placeholder="Pseudo" name="pseudo"> <br>
Mail: <input type="email" placeholder="Mail" name="mail"> <br>
Commentaire: <textarea  placeholder="Commentaire" name="commentaire"></textarea> <br>
<input type="hidden" name="date" value="<?php echo time(); ?>"><br>
<input type="hidden" name="messages_id" value="<?php echo $donneesmsg['id']; ?>"><br>           
<input type="text" name="commentaires_id" value="<?php echo $_GET['com']; ?>"><br>
<input type="hidden" name="id" value="<?php echo $donneesmsg['id']; ?>"><br>
<input type="submit" value="Envoyer">
</form>
4

0 回答 0