Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8556105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:16:14+00:00 2026-06-11T15:16:14+00:00

I have a simple PHP while loop which executes a list of tabular comments/posts

  • 0

I have a simple PHP while loop which executes a list of tabular comments/posts from the SQL database. Each post has a reply hyperlink that that will open a textarea (form) below the post which will allow the user to reply to that specific post. It works fine for one post, but when there are multiple posts the jQuery opens all of the textareas for each post. I assume that this is an issue with me calling identical classes using jQuery. But I am not sure how to deal with it. What I would like to achieve is allowing the user to click on a reply hyperlink within a specific post and only that textarea will appear underneath and not all of them at the same time.

Here is the PHP code to generate the list of posts with the reply feature.

<?php>

echo "<table width=\"100%\" border=\"0\" cellspacing=\"10\">";

while ($row2 = mysql_fetch_assoc($res)) 
{

echo "
   <tr>
   <td>
      <span class=\"anonname\">Anon" . $row2['uid'] . " </span> 
      <span class=\"smalltext\"> says:</span>
   </td>
   </tr>
   <tr>
   <td>
      <span class=\"messagetext\">" . $row2['msg'] . "</span></td>
   </tr>
   <tr>
   <td>
       <div class=\"replystyle\"><span class=\"replytext\"><a href=\"#\"  
       class=\"replybtn\">Reply</a> &#8901; <a href=\"#\">Like</a> </span> <span              
       class=\"replytext\" style=\"float:right;\"><span class=\"timetext\">" .         
       $row2['timestamp'] . "</span><a href=\"report.html\">Report</a></span></div>
   </td>
   </tr>
   <tr>
   <td>
       <div id=\"replymsgbox\">
       <form id=\"messaging\" action=\"\" method=\"post\" accept-charset=\"UTF-8\"> 
       <div class=\"tarea\">
       <textarea name=\"message\" rows=\"2\" class=\"txtbx\"></textarea>
       </div>
   <span style=\"float:right;\"><input name=\"submit\" class=\"signupbtn\"          
       type=\"submit\" value=\"share\" /></span><br/><br/>
       </form>
   </div>
  </td>
  </tr>";
}
       echo "</table>";
}
?>

Here is the jQuery

<script language="javascript" type="text/javascript"> 
  $(document).ready(function(){
            $('.replymsgbox').hide();
    $('.replybtn').click(function(){
    $('.replymsgbox').slideToggle('fast');
       });
       });
</script>     

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:16:15+00:00Added an answer on June 11, 2026 at 3:16 pm

    With $('.replymsgbox') selector, you are getting all the element having such class.

    To get just the one related to the button, use:

    $('.replybtn').click(function(){
        $('.replymsgbox', $(this).parent().parent().next()).slideToggle('fast');
    });
    

    You are narrowing research of a .replymsgbox element inside next <tr> this way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here I have a simple php script which displays some values from a database
I have this simple while loop which retrieves data from a mysql query and
I have a simple php page that displays data from a mysql database. I
I have setup a simple while loop which returns all images in a table
I have a simple query in php on oracle: $query='select u.username,u.lastname,u.firstname,c.event,c.reason from users u,
I have a simple working PHP script to write an HTML table from a
So I have this simple PHP loop that is generating html table data with
I have the following simple mysqli php application, which should work fine. $pk is
I have a very simple PHP form, which shows a checkbox, and will store
I have simple php validation form that is halfway working. If you leave the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.