jquery - Tablesorter, PHP and AJAX -
i have problem when try sort table tablesorter.js. looks easy use it, in case doesn't work... first of all, explain application:
1.- have database several data
2.- developed web interface search data (html)
3.- wanted make interactive communication database, used ajax
4.- build querys , table results in php file
so, in html file:
<div id = "divresults"></div>
and in header of file added jquery , tablesorter.js references , css file contento of css tablesorter
$(document).ready(function() { $("#mytable").tablesorter(); } );
now, in php file have following code:
<table id="mytable" class="tablesorter" style="font-size: 8pt; position:relative; top: -10px;" > <thead> <tr> <th><b>col1</b></th> <th><b>col2</b></th> <th><b>col3</b></th> <th><b>col4</b></th> <th><b>col5</b></th> </tr> </thead> <tbody> <?php ($i = 0; $i<$n;$i++) { $result_array = ordenar_array($result_array,2, sort_asc,3,sort_asc); echo "<tr>"; ($aux = 0; $aux<5;$aux++) { echo "<td> ".$result_array [$i][$aux]."</td>"; } echo "</tr>"; } echo "</tbody>"; echo "</table>"; ?>
the table it's ok, data ok , display in correct way, can't sort function. me?
edit: code added css file:
/* tables */ table.tablesorter { font-family:arial; background-color: #cdcdcd; margin:10px 0pt 15px; font-size: 8pt; width: 100%; text-align: left; } table.tablesorter thead tr th, table.tablesorter tfoot tr th { background-color: #e6eeee; border: 1px solid #fff; font-size: 8pt; padding: 4px; } table.tablesorter thead tr .header { background-image: url(../img/bg.gif); background-repeat: no-repeat; background-position: center right; cursor: pointer; } table.tablesorter tbody td { color: #3d3d3d; padding: 4px; background-color: #fff; vertical-align: top; } table.tablesorter tbody tr.odd td { background-color:#f0f0f6; } table.tablesorter thead tr .headersortup { background-image: url(../img/asc.gif); } table.tablesorter thead tr .headersortdown { background-image: url(../img/desc.gif); } table.tablesorter thead tr .headersortdown, table.tablesorter thead tr .headersortup { background-color: #8dbdd8; }
Comments
Post a Comment