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

  • Home
  • SEARCH
  • 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 257167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:04:28+00:00 2026-05-11T22:04:28+00:00

I have a table of data from mysql rendered on page via PHP into

  • 0

I have a table of data from mysql rendered on page via PHP into a HTML table.

Within this table of data, I have a row of data that should be focussed on (let’s call it) row X.

I want the 2 rows above and below row X to be shown but all others hidden, as row X moves up and down, this would change (obviously) what was hidden, when row X is at the top/bottom I want to show 4 rows below/above.

I have done this with static content and JQuery, I am just unsure how to track row X and then apply the class names as required

  • 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-05-11T22:04:28+00:00Added an answer on May 11, 2026 at 10:04 pm

    I thought this was an interesting request so I threw up an example here. The interesting part is the selectors to select the siblings to display. Here is a function i wrote.

    function rowXMoved()
    {
      // hide all rows besides rowX
      $('.tableCSS tr:not(.rowX)').hide();
      if($('.rowX').prev('tr').size() == 0)
      {
        // we are row number 1, show 4 more
        $('.rowX').siblings('tr:lt(4)').show(); //:lt is less than(index)
      }
      else if($('.rowX').next('tr').size() == 0)
      {
        // we are the last row
        // find the index of the tableRow to show.
        var rowCount = $('.tableCSS tr').size();
        $('.rowX').siblings('tr:gt(' + (rowCount - 6) +')').show(); //:gt is greater than(index)
      }
      else
      {
        // show 2 rows before and after the rowX
        // there is probably a better way, but this is the most straight forward
        $('.rowX').prev('tr').show().prev('tr').show();
        $('.rowX').next('tr').show().next('tr').show();
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to return data fetched from MySQL table into a php file as
I have a php file that receives data from mySQL table. The mySQL table
Many applications have grids that display data from a database table one page at
I have table rows of data in html being filled from a CGI application.
I have a main table that I must get data from. I have a
I have data from a table in a database (string) that contain text and
I have to delete some rows from a data table. I've heard that it
Alright, so I have a table outputting data from a MySQL table in a
I have a table of data sorted by date, from which a user can
I need to extract data from my MySQL database into multiple text files. I

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.