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 7817839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:22:38+00:00 2026-06-02T06:22:38+00:00

i have this code bellow , i have first table which i get its

  • 0

i have this code bellow , i have first table which i get its data by while loop. and i have one row in this table which is ‘More Details’ with every line button of ‘Details’ .
i have tried this code of jquery but it works only with the first button ,
say that i have 10 lines in table with 10 buttons of course , so only the firt button works and show the ‘table2’ , but the other buttons dont work .
i have think that maybe i can pass a variable to jquery which determine on which button user have clicked to show the table2 which is relativ with this button.
i have googled this but google make me down , no result.
any help would be very appreciated.

<script src="http://code.jquery.com/jquery-latest.js"></script>
    <?php 
        $sql3= mysql_query("SELECT * FROM data  ");
        while($row3 =mysql_fetch_array($sql3)){
    ?>
<script>

$(document).ready(function() {
    $('#showr').click(function(){
        $('#Table2').show();
    });
});
</script>


    <table width='100%' border='1' cellspacing='0' cellpadding='0'>
        <th>Weeks</th>
        <th>date</th>
        <th>place</th>
        <th>More Details</th>
        <tr>
<?php 
        echo "<tr ><td style= 'text-align : center ;'>my rows1</td>" ;
        echo "<td style= 'text-align : center ;'>myrows2</td>";
        echo "<td  style= 'text-align : center ;'> myrows3</td>";
        echo "<td style= 'text-align : center ;'><button id='showr'>More Details</button></td></tr>";
}
?>
</tr>
</table><br />

<div id= "Table2" style= "display:none;">
    <table width='100%' border='1' cellspacing='0' cellpadding='0'>
        <th>try</th>
        <th>try2</th>
        <tr>
            <td>try3</td>
            <td>trs</td>
        </tr>
    </table>
</div>
  • 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-02T06:22:40+00:00Added an answer on June 2, 2026 at 6:22 am

    If you want to have each button show a different table, I would use ids to create a relationship between the button and the table. I presume that you’re using an auto-incrementing primary key in your table; if not, you could just put a counter in the loop and use that as the id.

    A lot of the code for outputting valid tables is left out below.

    <?php
    while($row3 = mysql_fetch_array($sql3)){
    //output your normal table rows
    
    //presuming a numeric primary key to use as id
    echo "<td><button id='showr_" . $row3['primaryKey'] . "' class='showr'>Show Details</button></td>";
    
    
    }
    ?>
    
    <?php
    //reset mysql data set so we can loop through it again to output the second tables
    mysql_data_seek($sql3, 0);
    while($row3 = mysql_fetch_array($sql3)){
    //output hidden table
    echo "<table style='display: none' class='table2' id='table2_" . $row3['primaryKey'] . "'>";
    //output rest of rows here...
    echo "</table>";
    ?>
    

    The Javascript will see that a button is clicked, grab the id for that button, and show the relevant table while hiding any table that might currently be showing.

    <script type='text/javascript'>
    $(document).ready(function() {
        $('.showr').click(function(){
            //get id by splitting on the underscore within the 'id' attribute
            //$(this) refers to the button that has been clicked
            var id = $(this).attr('id').split('_')[1];
    
            //hide all table2's and then show the one we want
            $('.table2').hide();
            $('#Table2_' + id).show();
        });
    });
    </script>
    

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

Sidebar

Related Questions

Racking my brains on this one. I have the code below: the first stages
i have done some code in jquery but where i commented in this bellow
I have the code below and I want to loop this every 5 seconds.
I have this ant script which should create the table customer. I see the
I have a table which I want to get the latest entry for each
This is what I want to know. I have a table which has the
Note: I think this is technically still code-first but I have an existing database
I have this code below. As you can see I am passing two variables
I have this code below: $insert = array(); for ($i = 1, $n =
I have this javascript code below that uses jquery, it is suppoed to be

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.