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.
<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>

Open in new window

Bade011Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert SchuttSoftware EngineerCommented:
1) Did you download the plugin? And upload to your webserver? You also need to reference it in your header, below the jquery reference, for example:
<script src="jquery.tablesorter.min.js"></script>

Open in new window


2) the html mark-up for your table is missing thead/tbody tags, these are needed according to the documentation (introduction).

3) Choose one of the initialisation functions, no need to call it twice.

I have placed a sample output file here: http://schutt.nl/ee/Q_28712474/
<!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="style.css">
		<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
		<script src="http://tablesorter.com/__jquery.tablesorter.min.js"></script>
		<script>
		  $(document).ready(function() 
		    { 
			$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} ); 
		    } 
		); 
</script>
</head>
<body>
  <div id="main">
<table id= 'myTable' class='tablesorter' width='100%' cellpadding='0' cellspacing='0' border='1px'>
<thead><tr><th  colspan='1'>ID</th><th  colspan='1'>Date</th><th  colspan='1'>Title</th><th  colspan='1'>Author</th><th colspan='1'>Image Name</th></tr></thead><tbody>
<tr><td  colspan='1'>id 73</td><td  colspan='1'>date 58</td><td  colspan='1'>title 62</td><td class='tdcell' colspan='1'>name 36</td><td class='tdcell' colspan='1'>img 37</td></tr>
<tr><td  colspan='1'>id 79</td><td  colspan='1'>date 11</td><td  colspan='1'>title 78</td><td class='tdcell' colspan='1'>name 83</td><td class='tdcell' colspan='1'>img 73</td></tr>
<tr><td  colspan='1'>id 14</td><td  colspan='1'>date 47</td><td  colspan='1'>title 87</td><td class='tdcell' colspan='1'>name 81</td><td class='tdcell' colspan='1'>img 43</td></tr>
<tr><td  colspan='1'>id 96</td><td  colspan='1'>date 88</td><td  colspan='1'>title 15</td><td class='tdcell' colspan='1'>name 95</td><td class='tdcell' colspan='1'>img 42</td></tr>
<tr><td  colspan='1'>id 57</td><td  colspan='1'>date 79</td><td  colspan='1'>title 14</td><td class='tdcell' colspan='1'>name 63</td><td class='tdcell' colspan='1'>img 52</td></tr>
<tr><td  colspan='1'>id 36</td><td  colspan='1'>date 66</td><td  colspan='1'>title 68</td><td class='tdcell' colspan='1'>name 33</td><td class='tdcell' colspan='1'>img 35</td></tr>
<tr><td  colspan='1'>id 84</td><td  colspan='1'>date 84</td><td  colspan='1'>title 63</td><td class='tdcell' colspan='1'>name 98</td><td class='tdcell' colspan='1'>img 91</td></tr>
<tr><td  colspan='1'>id 30</td><td  colspan='1'>date 72</td><td  colspan='1'>title 98</td><td class='tdcell' colspan='1'>name 31</td><td class='tdcell' colspan='1'>img 58</td></tr>
<tr><td  colspan='1'>id 19</td><td  colspan='1'>date 99</td><td  colspan='1'>title 70</td><td class='tdcell' colspan='1'>name 11</td><td class='tdcell' colspan='1'>img 61</td></tr>
<tr><td  colspan='1'>id 19</td><td  colspan='1'>date 19</td><td  colspan='1'>title 81</td><td class='tdcell' colspan='1'>name 35</td><td class='tdcell' colspan='1'>img 14</td></tr>
<tr><td  colspan='1'>id 36</td><td  colspan='1'>date 44</td><td  colspan='1'>title 37</td><td class='tdcell' colspan='1'>name 95</td><td class='tdcell' colspan='1'>img 98</td></tr>
<tr><td  colspan='1'>id 46</td><td  colspan='1'>date 35</td><td  colspan='1'>title 24</td><td class='tdcell' colspan='1'>name 24</td><td class='tdcell' colspan='1'>img 68</td></tr>
<tr><td  colspan='1'>id 46</td><td  colspan='1'>date 47</td><td  colspan='1'>title 74</td><td class='tdcell' colspan='1'>name 39</td><td class='tdcell' colspan='1'>img 66</td></tr>
<tr><td  colspan='1'>id 28</td><td  colspan='1'>date 26</td><td  colspan='1'>title 62</td><td class='tdcell' colspan='1'>name 17</td><td class='tdcell' colspan='1'>img 51</td></tr>
<tr><td  colspan='1'>id 91</td><td  colspan='1'>date 33</td><td  colspan='1'>title 80</td><td class='tdcell' colspan='1'>name 44</td><td class='tdcell' colspan='1'>img 36</td></tr>
<tr><td  colspan='1'>id 92</td><td  colspan='1'>date 66</td><td  colspan='1'>title 66</td><td class='tdcell' colspan='1'>name 48</td><td class='tdcell' colspan='1'>img 18</td></tr>
<tr><td  colspan='1'>id 60</td><td  colspan='1'>date 72</td><td  colspan='1'>title 92</td><td class='tdcell' colspan='1'>name 85</td><td class='tdcell' colspan='1'>img 12</td></tr>
<tr><td  colspan='1'>id 58</td><td  colspan='1'>date 92</td><td  colspan='1'>title 48</td><td class='tdcell' colspan='1'>name 71</td><td class='tdcell' colspan='1'>img 55</td></tr>
<tr><td  colspan='1'>id 56</td><td  colspan='1'>date 51</td><td  colspan='1'>title 41</td><td class='tdcell' colspan='1'>name 46</td><td class='tdcell' colspan='1'>img 34</td></tr>
<tr><td  colspan='1'>id 15</td><td  colspan='1'>date 31</td><td  colspan='1'>title 98</td><td class='tdcell' colspan='1'>name 15</td><td class='tdcell' colspan='1'>img 45</td></tr>
<tr><td  colspan='1'>id 42</td><td  colspan='1'>date 54</td><td  colspan='1'>title 24</td><td class='tdcell' colspan='1'>name 52</td><td class='tdcell' colspan='1'>img 33</td></tr>
<tr><td  colspan='1'>id 66</td><td  colspan='1'>date 58</td><td  colspan='1'>title 24</td><td class='tdcell' colspan='1'>name 94</td><td class='tdcell' colspan='1'>img 68</td></tr>
<tr><td  colspan='1'>id 55</td><td  colspan='1'>date 45</td><td  colspan='1'>title 19</td><td class='tdcell' colspan='1'>name 80</td><td class='tdcell' colspan='1'>img 51</td></tr>
<tr><td  colspan='1'>id 77</td><td  colspan='1'>date 63</td><td  colspan='1'>title 84</td><td class='tdcell' colspan='1'>name 11</td><td class='tdcell' colspan='1'>img 28</td></tr>
<tr><td  colspan='1'>id 16</td><td  colspan='1'>date 19</td><td  colspan='1'>title 39</td><td class='tdcell' colspan='1'>name 21</td><td class='tdcell' colspan='1'>img 10</td></tr>
<tr><td  colspan='1'>id 58</td><td  colspan='1'>date 69</td><td  colspan='1'>title 58</td><td class='tdcell' colspan='1'>name 84</td><td class='tdcell' colspan='1'>img 17</td></tr>
<tr><td  colspan='1'>id 27</td><td  colspan='1'>date 71</td><td  colspan='1'>title 50</td><td class='tdcell' colspan='1'>name 42</td><td class='tdcell' colspan='1'>img 23</td></tr>
<tr><td  colspan='1'>id 73</td><td  colspan='1'>date 93</td><td  colspan='1'>title 57</td><td class='tdcell' colspan='1'>name 18</td><td class='tdcell' colspan='1'>img 78</td></tr>
<tr><td  colspan='1'>id 46</td><td  colspan='1'>date 51</td><td  colspan='1'>title 54</td><td class='tdcell' colspan='1'>name 28</td><td class='tdcell' colspan='1'>img 39</td></tr>
</tbody></table>

		</div>
	</body>
</html>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.