(editing to make this more clear)
I'm using ajax to create a whole table and initialize jquery.tablesorter. This works fine, except when I try to order by column, all the data disappears from the table.
Code from the ajax file:
$resultRaw = mysql_query($queryFrame);
if($resultRaw and @mysql_num_rows($resultRaw))
{
$row_count = mysql_num_rows($resultRaw);
$dataTable = 'Count: ' . $row_count . ' <br /><script> $("table").tablesorter({widthFixed: true, widgets: ["zebra"]}).tablesorterPager({container: $("#pager")}); </script> <table cellspacing=".2" class="tablesorter">';
$data = '';
while($rowData = mysql_fetch_assoc($resultRaw))
{
$data .= '<tr>';
$headers = array();
foreach($rowData as $header => $dataEntry)
{
$data .= '<td>' . $dataEntry . '</td>';
//This will get rewritten every turn...
$headers[] = $header;
}
$data .= '</tr>';
}
$dataTable .= '<thead><tr>';
foreach($headers as $singleHeader)
{
$dataTable .= '<th>' . $singleHeader . '</th>';
}
$dataTable .= '</tr></thead><tbody>' . $data . '</tbody></table><div id="pager"></div><script> $("table").trigger("update"); </script> ';
}
else
{
echo 'No results returned.';
}
echo $dataTable;