我目前有一个填充了mysql数据的表,我有一些jquery代码来分页数据。这工作正常,但是,我也使用jquery.tablesorter.min.js对表进行排序。这仅适用于第一页,只要您更改页面,它就会对该页面上的数据进行排序,而不是将所有数据排入表中。我需要能够在单击列标题时对所有数据进行排序,而不仅仅是该页面上由以下分页代码解析的数据:
的tablesorter:
<script>
$(document).ready(function() {
$("#sortedtable").tablesorter({ sortlist: [0,0] });
});
</script>
分页:
<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>";
?>
免责声明我知道我应该使用mysql完成,我会在项目完成后立即