Hello .
Im trying to submit a form that is inside a php while loop ( im using the loop to fitch data from the database , and depends on how many data that been fetched the from will be generated ) so if we have 4 rows from the data we will have 4 forms .

My problem is when i submit the first form it do submit perrty good , but when i try to submit anyother form it submit but the textarea keeps passing empty value , dont know whey .

I did cut only the form code cause my code is so long , im passing the values to another page using ajax .

<html>
<head>

</head>
<body>

<?php 
    while($FR = $FetchReply->FETCH(PDO::FETCH_ASSOC))
    { 
        $user_id = $FR['replier_id'];
        $FetchReplyerInfo = $conn->prepare("SELECT * FROM users WHERE user_id = ?");
        $FetchReplyerInfo->execute([$user_id]);
        $FRI = $FetchReplyerInfo->fetch(PDO::FETCH_ASSOC);
        $username = $FRI['username'];
        ?>
            <form action="" method="POST" onsubmit="return SubmitComment('reply', <?php echo $FUI['user_id']; ?>, null, <?php echo $FC['id']; ?>);">
                <div class="form-group">
                    <textarea class="form-control" id="reply" rows="3" placeholder="* Your comment here" required></textarea>
                </div>
                <button type="submit" class="btn btn-theme btn-md">Reply</button>
            </form>
        <?php 
    } ?>

</body>
</html>

This is due to during the looping, textarea with same id id="reply" created. Try change the id into class.

commented: id and class do the same thing, but you can apply class to multiple elements +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.