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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:09:24+00:00 2026-05-30T00:09:24+00:00

Here’s the issue: I’m using JQuery tablesorter to paginate a table. Table rows are

  • 0

Here’s the issue: I’m using JQuery tablesorter to paginate a table. Table rows are fetched from database, like this:

//list players by points (default listing)
$result=mysql_query("select * from players order by pts_total") or die(mysql_error());
echo "<table id='list_table' class='tablesorter'><thead><tr><th width='25px'>Pos</th><th width='200px'>Player</th><th width='25px'>Club</th><th width='25px'>Value</th><th width='25px'>Points</th></tr></thead><tbody>";
while($row=mysql_fetch_array($result)){
    //get team logo
    $result1=mysql_query("select amblem from real_teams where team_name='$row[team]' ") or die(mysql_error());
    $row1=mysql_fetch_array($result1);
    echo "<tr>";
    echo "<td>T</td>";
    echo "<td>".$row['name']."</td>";
    echo "<td style='text-align:center;'><img src='".$row1['amblem']."' height=16px title='".$row['team']."'></td>";
    echo "<td>".$row['current_value']."</td>";
    echo "<td>".$row['pts_total']."</td>";
    echo "</tr>";
}
echo "</tbody></table>";

That all works fine, the table is paginated, it lists football players. But the thing is, I have a dropdown where the user should be able to choose to display only players who play a certain position (that info is in the same database table):

<select name="show_positions" id="show_positions" onChange="showPlayers(this.value)">
<option value="A">All Positions</option>
<option value="G">Goalkeepers</option>
<option value="D">Defenders</option>
<option value="M">Midfielders</option>
<option value="S">Strikers</option>
</select>

It calls an Ajax function which displays a table with only players who play a certain position, and it does what it’s supposed to but the table is no longer paginated. Instead it display one big table. I assume it’s because the Javascript that paginates it isn’t processed since the page isn’t being reloaded? Is there a way to call the Javascript function again during the Ajax call? Here’s the Ajax and the PHP file it calls:

<script type="text/javascript">
function showPlayers(str)
{
if (str=="")
  {
  document.getElementById("inner_list").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("inner_list").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","listplayers.php?q="+str,true);
xmlhttp.send();
}
</script>

listplayers.php:

<?php
include('../include/db.php');
dbConnect('dbname');

$pos=$_GET['q'];
if ($pos=="A")
    $pos="";

//list players by points (default listing)
$result=mysql_query("select * from players where position LIKE '%$pos%' order by pts_total") or die(mysql_error());
echo "<table id='list_table' class='tablesorter'><thead><tr><th width='25px'>Pos</th><th width='200px'>Player</th><th width='25px'>Club</th><th width='25px'>Value</th><th width='25px'>Points</th></tr></thead><tbody>";
while($row=mysql_fetch_array($result)){
    //get team logo
    $result1=mysql_query("select amblem from real_teams where team_name='$row[team]' ") or die(mysql_error());
    $row1=mysql_fetch_array($result1);
    echo "<tr>";
    echo "<td>T</td>";
    echo "<td>".$row['name']."</td>";
    echo "<td style='text-align:center;'><img src='".$row1['amblem']."' height=16px title='".$row['team']."'></td>";
    echo "<td>".$row['current_value']."</td>";
    echo "<td>".$row['pts_total']."</td>";
    echo "</tr>";
}
echo "</tbody></table>";
?>

And the tablesorter JQuery, which is in the head of the page:

<script type="text/javascript">
$(document).ready(function() { 
    $("table") 
    .tablesorter({widthFixed: true, widgets: ['zebra']}) 
    .tablesorterPager({container: $("#pager"), size: 20}); 
}); 
</script>
  • 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-30T00:09:25+00:00Added an answer on May 30, 2026 at 12:09 am

    in the callback handler, aftyer you inserted the table in the DOM, you should call the tablesorter plugin again on the table to re-initialize it

    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
      document.getElementById("inner_list").innerHTML=xmlhttp.responseText;
      $("#list_table").tablesorter( );
    }
    

    To be sure to use always the same options you could save them in an object

    $(document).ready(function(){
       var list_table_options = {sortList: [[0,0], [1,0]]};
      $("#list_table").tablesorter( list_table_options );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here's a coding problem for those that like this kind of thing. Let's see
Here is the issue I am having: I have a large query that needs
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
I am reading a book about Javascript and jQuery and using one of the
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is the css: #content ul { font-size: 12px; } I am trying this:
Here my problem: @Assert\Regex( * pattern=/^[A-Za-z0-9][A-Za-z0-9\]*$/, * groups={creation, creation_logged} * ) I'm using the
Here's an example query: DECLARE @table table (loc varchar(10)) INSERT INTO @table VALUES ('134a'),
Here is a simple timepicker to jQuery UI's datepicker <script type=text/javascript> /* <![CDATA[ */

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.