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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:26:34+00:00 2026-06-12T04:26:34+00:00

So I have a table generated from database with while loop. Data is displayed

  • 0

So I have a table generated from database with while loop. Data is displayed in rows. Point is that there are “hidden” rows with data available only on click (like show details). Basically I want something like this: http://www.transfercar.co.nz/ – if you click on the table row more data appears below (in new row).

My code looks like this:

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$display1=$display1+1;
    echo '
    <tr class="tablerow">
        <td>' . $row['id'] . '</td>
        <td><p class="state">' . $row['name'] . '</p></td>
        <td><p class="state">' . $row['surname'] . '</p></td>
        <td>' . $row['country'] . '</td>
        <td>' . $row['city'] . '</td>
        <td>' . $row['category'] . '</td>
    </tr>';
if($row['id']==$_GET['showrow'])
{
    echo '
    <tr class="subtable" style="display:none;">';
        echo '<td colspan="3" class="detalji"></td>
        <td align="left" colspan="3" class="detalji"></td>
        </tr>';}} // End of WHILE loop.
echo '</table>';

My jQuery looks like this:

/* Table row click */
$(".tablerow").click(function()
{
  $(".subtable").show();
}); 

$(".subtable").click(function()
{
  $(".subtable").hide();
}); 

Point is that once clicked all subtables show, naturally I only want the one below the clicked table row..

  • 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-12T04:26:35+00:00Added an answer on June 12, 2026 at 4:26 am

    I have managed to solve it using code like this:

    $(".tablerow").click(function()
    {
      $(this).next(".subtable").slideDown("slow");
    }); 
    
    $(".subtable").click(function()
    {
      $(".subtable").hide();
    });
    

    sushanth reddy has been very helpful, thank you! I am not exactly sure why this code works and Sushanth is not. There is probably a typo somewhere, but anyway Susanth provided with correct answer and therefore i will edit his reply with correct code.

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

Sidebar

Related Questions

I have a collection of entities that I generated from a database. One table
I have a table that has sortable rows. The table is generated from a
I Have an Entity generated from a database table. Then I add a property
I have an html table containing values that are being generated from javascript. How
I have a table of data that is generated dynamically based on the contents
I have two classes generated by LINQ2SQL both from the same table so they
I have a dynamically generated table and for each row in the table there
I have an Entity Framework generated table with values in a td that I
Fiddle: http://jsfiddle.net/MhWm5/16/ I have some dynamically generated table rows/values with dynamic IDs <td class=control-group>
I have a database from which I want to query and display only that

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.