I currently have a table that is populated with mysql data and I have the some jquery code to paginate the data. This works fine, however, I am also using jquery.tablesorter.min.js to sort the tables. This only works on the first page, as soon as you change the page, it only sorts the data on that page instead of all of the data that is being pulled into the table. I need to be able to sort all of the data when clicking the column headers, not just the data on that page that was parsed by the following pagination code:
tablesorter:
<script>
$(document).ready(function() {
$("#sortedtable").tablesorter({ sortlist: [0,0] });
});
</script>
pagination:
<script type="text/javascript">
$(document).ready(function() {
//Declaring Variables
var page = 1;
var per_page = 20;
var items = $('.row').length;
var page_last = Math.ceil(items/per_page);
//Set Page
function setPage(page) {
$('.row').slice(0, page * per_page).hide();
$('.row').slice(page * per_page - per_page, page * per_page).show();
$('.row').slice(page * per_page).hide();
$('#page_display').html('Page ' + page + ' of ' + page_last);
}
//Next Button
$('.next').click(function() {
if (page < page_last) {
page++;
setPage(page);
}
});
//Previous Button
$('.prev').click(function() {
if (page > 1) {
page--;
setPage(page);
}
});
setPage(1);
});
</script>
php/mysql
$cbsql = "SELECT patient_id, AES_DECRYPT(firstName,'$key') as firstName, AES_DECRYPT(lastName,'$key') as lastName, AES_DECRYPT(telephone1,'$key') as telephone1, AES_DECRYPT(email,'$key') as email, cbdate, status, owner FROM patientprofiles WHERE owner = '$owner' and cbdate <= '$today' AND cbdate != 0000-00-00 ORDER BY cbdate ASC";
$mycbData = mysql_query($cbsql,$con);
echo "<table id=sortedtable>
<thead>\n<tr>
<th>Date</th>
<th>Patient</th>
<th>Phone</th>
<th>Email</th>
</tr>\n</thead>\n";
while($record=mysql_fetch_array($mycbData)){
$mysql_cbdate = date('m/d/Y', strtotime($record['cbdate']));
echo "<tr class=row>";
echo "<td>" .$mysql_cbdate. "</td>";
echo "<td>" . stripslashes($record['lastName']) . ", " .$record['firstName'] . "</td>";
echo "<td>" .$record['telephone1']. "</td>";
echo "<td>" .$record['email']. "</td>";
echo "</tr>";
}
echo "</table>";
?>
Disclaimer I know I should be done using mysql and I will be as soon as this project is finished