Jump to content

Table sorting and paging problem


richrock

Recommended Posts

I've found an excellent set of scripts to run tables and page results, keeping the sorting order across the pages.  Yet the documentation is non-existent for the paging...

 

There is a demo online, and I've followed it to the letter, except for the fact I'm using a while loop from php to display the results.  Yet I can't get any paging to come up, let alone sort properly...

 

Here's the head part :

 

<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript" src="/addons/pager/jquery.tablesorter.pager.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("table")
        .tablesorter({widthFixed: true, widgets: ['zebra']})
        .tablesorterPager({container: $("#pager")});
    });
    
</script>

 

And the body where the table happens:

 

<table cellpadding="2" cellspacing="0" border="1" id="myTable">
<?php

//echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";

echo "<thead>";
    echo "<th width=\"150\">Surname</th>";
    echo "<th width=\"50\">Year  <a href=\"yearbook.php?option=sortyrup\"><img src=\"images/arrow-up.png\" border=\"0\" />";
    echo "</a> <a href=\"yearbook.php?option=sortyrdn\"><img src=\"images/arrow-dn.png\" border=\"0\" /></a></th>";
    echo "<th width=\"100\">Instrument Type</th>";
    echo "<th width=\"50\">Country</th>";
    echo "<th width=\"50\">City</th>";
    echo "<th width=\"100\">Auction House</th>";
    echo "<th width=\"100\">Sale Date</th>";
    echo "<th width=\"50\">Lot No.</th>";
    echo "<th width=\"50\">Sale Price</th>";
    echo "</thead>";
    echo "<tbody>";
//echo "</form>";

while ($rowYBRes = mysql_fetch_array($YBResult)) {
    $YBlname = $rowYBRes['surname'];
    $YByear = $rowYBRes['year'];
    $YBinstrument = $rowYBRes['instr_type'];
    $YBcountry = $rowYBRes['country'];
    $YBcity = $rowYBRes['city'];
    $YBlotnum = $rowYBRes['lot_number'];
    $YBhouse = $rowYBRes['auction_house'];
    $YBmonth = $rowYBRes['month'];
    $YBarchive_year = $rowYBRes['archive_year'];
    $YBArchiveDate = $YBmonth." ".$YBarchive_year;
    $YBprice_gbp = $rowYBRes['value_gbp'];

    //$YBPrice = $YBprice_gbp;
    //$YBPRice =preg_replace("/[^0-9]/","", $YBPrice);
    
    //print $string."<br />";
   // echo "<tbody>";
        echo "<tr>";
            echo "<td>".$YBlname."</td>";
            echo "<td>".$YByear."</td>";
            echo "<td>".$YBinstrument."</td>";
            echo "<td>".$YBcountry."</td>";
            echo "<td>".$YBcity."</td>";
            echo "<td>".$YBhouse."</td>";
            echo "<td >".$YBArchiveDate."</td>";
            echo "<td>".$YBlotnum."</td>";
            echo "<td>".$YBprice_gbp."</td>";
        echo "</tr>";
   // echo "</tbody>";

}
echo "</tbody>";
?>

</table>
<div id="pager" class="pager"></div>

 

Not sure whats happening here, as my js skills are really rusty.  I assume from reading the source code that the paging is generated by the js file.

 

I tried updating the jquery file and that made no difference.  Here's a link to the page with the plugin working (annoyingly) : http://tablesorter.com/docs/example-pager.html

 

any ideas?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.