When executing this script

<?php $name = $_POST ['user']; $comment = $_POST ['comment']; $str = ":"; for ($i = 0; $i < count($name); $i++){ $s = $_POST['namepost'] . $name . ":" . "<br />"; } for ($j = 0; $j < count($comment); $j++){ $st = $_POST['namepost2'] . $comment . "<br />"; } ?> <form name="someform" method="post"> <p><b>Π’Π°ΡˆΠ΅ имя:</b><br> <input type="text" size="40" name="user"> <input type="hidden" name="namepost" value="<?=$s?>"> <input type="hidden" name="namepost2" value="<?=$st?>"> </p> <p><b><?=$s?></b><?=$st?></p> <p><textarea name="comment" cols="40" rows="3" placeholder="Π’Π²Π΅Π΄ΠΈΡ‚Π΅ ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ"></textarea></p> <p><input type="submit" value="ΠžΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ"> </form> 

If you enter for example a couple of comments from the relevant users, the following picture is displayed above the comment input field:

I:

Is he:

ahhh

Yu

And you need to display one by one:

I: ahhh

He: Yu

    1 answer 1

    Try the following code:

     <?php $name = $_POST ['user']; $comment = $_POST ['comment']; $str = ":"; for ($i = 0; $i < count($name); $i++){ $s = $_POST['namepost'] . $name . ": " . $_POST['namepost2'] . $comment . "<br />"; } ?> 
    • Thank you, Yaroslav. It works! - Beginner