Bade011
asked on
How to SQL sort the table in classic asp where data is retrieved from database?
Hi Experts,
I am trying to sort a table's date (by ascending and descending)and author name alphabetically. I have heard of "table sorter plugin" but I failed when I tried it. Attached is the code i am working on which doesn't work. I kept just to let you all know what and how i am working .I expected the date header with nice small arrow for sorting but couldn't get it. I hope you guys would help me out.
I am trying to sort a table's date (by ascending and descending)and author name alphabetically. I have heard of "table sorter plugin" but I failed when I tried it. Attached is the code i am working on which doesn't work. I kept just to let you all know what and how i am working .I expected the date header with nice small arrow for sorting but couldn't get it. I hope you guys would help me out.
<html>
<head>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
$(function() {
$("#myTable").tablesorter();
});
$(document).ready(function()
{
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
}
);
</script>
</head>
div id="main">
SQL STATEMENTS....
SET RS = objconn.execute(SQL)
IF NOT RS.EOF THEN
Response.Write "<table id= 'myTable' width='100%' cellpadding='0' cellspacing='0' border='1px'>"
Response.Write "<tr>"
Response.Write "<td colspan='1'>"
Response.Write "ID"
Response.Write "</td>"
Response.Write "<td colspan='1'>"
Response.Write "Date"
Response.Write "</td>"
Response.Write "<td colspan='1'>"
Response.Write "Title"
Response.Write "</td>"
Response.Write "<td colspan='1'>"
Response.Write "Author"
Response.Write "</td>"
Response.Write "<td colspan='1'>"
Response.Write "Image Name"
Response.Write "</td>"
Response.Write "</tr>"
While NOT RS.EOF
Response.Write "<tr>"
Response.Write "<td colspan='1'>"
Response.Write RS("id")
Response.Write "</td>"
Response.Write "<td colspan='1'>"
Response.Write RS("date")
Response.Write "</td>"
Response.Write "<td colspan='1'>"
Response.Write RS("title")
Response.Write "</td>"
Response.Write "<td class='tdcell' colspan='1'>"
Response.Write RS("firstname") & " " & RS("lastname")
Response.Write "</td>"
Response.Write "<td class='tdcell' colspan='1'>"
Response.Write RS("img")
Response.Write "</td>"
Response.Write "</tr>"
RS.Movenext
Wend
Response.Write "</table>"
END IF
RS.Close
Set RS = Nothing
END IF
%>
</div>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.