navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Sorting columns

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Sorting columns
Page: [1]
 
DesiMcK

 

Posts: 446
Joined: 4/26/2004
From: Essex, UK
Status: offline

 
Sorting columns - 4/28/2004 5:36:23   
Hi have two asp pages - 1) has a list of check boxes so the user can choose which info to display and 2) the results pages based on the user's choices.

I want to be able to click on the title of each column in order to sort the table by that column. I have been able to do this using a tutorial at http://www.frontpages-web-hosting.net/frontpage.Support/fron tpage.hta_7.htm. Unfortunately I can only get this to work if I show all database at once. Is there a way of sorting only the columns which the user chooses.

I have attached the code for the two pages so this may make more sense. The search form can be viewed at http://www.mrmckeown.com/Deanes/PupilData/SearchByClass.asp.

Thanks in advance,

Desi

------------Code for Page 1---------------

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>

<body>

<form BOTID="0" METHOD="POST" action="SearchByClassResults.asp">
<input type="hidden" name="fpdbr_0_PagingMove" value=" |< ">
<table BORDER="0">
<tr>
<td><b>Class</b></td& gt;
<td>
<select size="1" name="Class">
<option>Please select your class...</option>
<option>7A/Ma1</option>
<option>7A/Ma2</option>
<option>7A/Ma3</option>
<option>7A/Ma4</option>
<option>7B/Ma1</option>
<option>7B/Ma2</option>
<option>7B/Ma3</option>
<option>7B/Ma4</option>
<option>8A/Ma1</option>
<option>8A/Ma2</option>
<option>8A/Ma3</option>
<option>8A/Ma4</option>
<option>8B/Ma1</option>
<option>8B/Ma2</option>
<option>8B/Ma3</option>
<option>8B/Ma4</option>
<option>9A/Ma1</option>
<option>9A/Ma2</option>
<option>9A/Ma3</option>
<option>9A/Ma4</option>
<option>9B/Ma1</option>
<option>9B/Ma2</option>
<option>9B/Ma3</option>
<option>9B/Ma4</option>
<option>10B/Ma1</option>
<option>10B/Ma2</option>
<option>10B/Ma3</option>
<option>10B/Ma4</option>
<option>10B/Ma5</option>
<option>10G/Ma1</option>
<option>10G/Ma2</option>
<option>10G/Ma3</option>
<option>11B/Ma1</option>
<option>11B/Ma2</option>
<option>11B/Ma3</option>
<option>11B/Ma4</option>
<option>11B/Ma5</option>
<option>11G/Ma1</option>
<option>11G/Ma2</option>
<option>11G/Ma3</option>
</select></td>
</tr>
</table>
<table border="0" width="461" id="table2">
<tr>
<td width="152"><b>ExamNumber<input type="checkbox" name="ExamNumber" value="ON"></b></td>
<td width="152"><b>Gender<input type="checkbox" name="Gender" value="ON"></b></td>
<td width="153"><b>Form<input type="checkbox" name="Form" value="ON"></b></td>
</tr>
<tr>
<td width="152"><b>Year<input type="checkbox" name="Year" value="ON"></b></td>
<td width="152"><b>Band<input type="checkbox" name="Band" value="ON"></b></td>
<td width="153"><b>Set<input type="checkbox" name="Set" value="ON"></b></td>
</tr>
<tr>
<td width="152"><b>Class<input type="checkbox" name="Class" value="ON"></b></td>
<td width="152"><b>Teacher<input type="checkbox" name="Teacher" value="ON"></b></td>
<td width="153"> </td>
</tr>
<tr>
<td width="152"><b>Yr7TG<input type="checkbox" name="Yr7TG" value="ON"></b></td>
<td width="152"><b>Year7<input type="checkbox" name="Year7" value="ON"></b></td>
<td width="153"> </td>
</tr>
<tr>
<td width="152"><b>Yr8TG<input type="checkbox" name="Yr8TG" value="ON"></b></td>
<td width="152"><b>Year8<input type="checkbox" name="Year8" value="ON"></b></td>
<td width="153"> </td>
</tr>
<tr>
<td width="152"><b>YR9TG<input type="checkbox" name="YR9TG" value="ON"></b></td>
<td width="152"><b>SATsTier<input type="checkbox" name="SATsTier" value="ON"></b></td>
<td width="153"><b>KS3mg<input type="checkbox" name="KS3mg" value="ON"></b></td>
</tr>
<tr>
<td width="152"><b>SAS7<input type="checkbox" name="SAS7" value="ON"></b></td>
<td width="152"><b>SAS9<input type="checkbox" name="SAS9" value="ON"></b></td>
<td width="153"> </td>
</tr>
<tr>
<td width="152"><b>TMG3<input type="checkbox" name="TMG3" value="ON"></b></td>
<td width="152"><b>TMG3g<input type="checkbox" name="TMG3g" value="ON"></b></td>
<td width="153"> </td>
</tr>
<tr>
<td width="152"><b>Msat2<input type="checkbox" name="Msat2" value="ON"></b></td>
<td width="152"><b>Esat2<input type="checkbox" name="Esat2" value="ON"></b></td>
<td width="153"><b>Ssat2<input type="checkbox" name="Ssat2" value="ON"></b></td>
</tr>
<tr>
<td width="152"><b>Msat3<input type="checkbox" name="Msat3" value="ON"></b></td>
<td width="152"><b>Esat3<input type="checkbox" name="Esat3" value="ON"></b></td>
<td width="153"><b>Ssat3<input type="checkbox" name="Ssat3" value="ON"></b></td>
</tr>
<tr>
<td width="152"><b>KS4TG<input type="checkbox" name="KS4TG" value="ON"></b></td>
<td width="152"><b>GCSETier<input type="checkbox" name="GCSETier" value="ON"></b></td>
<td width="153"> </td>
</tr>
<tr>
<td width="152"><b>CW1<input type="checkbox" name="CW1" value="ON"></b></td>
<td width="152"><b>CW2<input type="checkbox" name="CW2" value="ON"></b></td>
<td width="153"><b>CW3<input type="checkbox" name="CW3" value="ON"></b></td>
</tr>
<tr>
<td width="152"><b>DataCW1<input type="checkbox" name="DataCW1" value="ON"></b></td>
<td width="152"><b>DataCW2<input type="checkbox" name="DataCW2" value="ON"></b></td>
<td width="153"><b>DataCW3<input type="checkbox" name="DataCW3" value="ON"></b></td>
</tr>
<tr>
<td width="152"><b>IEP<input type="checkbox" name="IEP" value="ON"></b></td>
<td width="152"> </td>
<td width="153"> </td>
</tr>
</table>
<br>
<input TYPE="Submit"><input TYPE="Reset"></form>

</body>

</html>

--------------and the code for page 2-----------------

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Pupil Data: Search By Class Results</title>
</head>

<body>

<table width="100%" border="1" id="table1">
<thead>
<tr>

<%If request.form("ExamNumber") = "ON" then%>
<th ALIGN="LEFT"><b>ExamNumber</b></th>
<%end if%>

<th ALIGN="LEFT"><b>Surname</b></th>

<th ALIGN="LEFT"><b>Name</b></th>

<%If request.form("Gender") = "ON" then%>
<th ALIGN="LEFT"><b>Gender</b></th>
<%end if%>
<%If request.form("Form") = "ON" then%>
<th ALIGN="LEFT"><b>Form</b></th>
<%end if%>
<%If request.form("Year") = "ON" then%>
<th ALIGN="LEFT"><b>Year</b></th>
<%end if%>
<%If request.form("Band") = "ON" then%>
<th ALIGN="LEFT"><b>Band</b></th>
<%end if%>
<%If request.form("Set") = "ON" then%>
<th ALIGN="LEFT"><b>Set</b></th>
<%end if%>
<%If request.form("Class") = "ON" then%>
<th ALIGN="LEFT"><b>Class</b></th>
<%end if%>
<%If request.form("Teacher") = "ON" then%>
<th ALIGN="LEFT"><b>Teacher</b></th>
<%end if%>

<%If request.form("IEP") = "ON" then%>
<th ALIGN="LEFT"><b>IEP</b></th>
<%end if%>
<%If request.form("Yr7TG") = "ON" then%>
<th ALIGN="LEFT"><b>Yr7TG</b></th>
<%end if%>
<%If request.form("Year7") = "ON" then%>
<th ALIGN="LEFT"><b>Year7</b></th>
<%end if%>
<%If request.form("Yr8TG") = "ON" then%>
<th ALIGN="LEFT"><b>Yr8TG</b></th>
<%end if%>
<%If request.form("Year8") = "ON" then%>
<th ALIGN="LEFT"><b>Year8</b></th>
<%end if%>
<%If request.form("Yr9TG") = "ON" then%>
<th ALIGN="LEFT"><b>YR9TG</b></th>
<%end if%>
<%If request.form("SAS7") = "ON" then%>
<th ALIGN="LEFT"><b>SAS7</b></th>
<%end if%>
<%If request.form("SAS9") = "ON" then%>
<th ALIGN="LEFT"><b>SAS9</b></th>
<%end if%>
<%If request.form("KS3mg") = "ON" then%>
<th ALIGN="LEFT"><b>KS3mg</b></th>
<%end if%>
<%If request.form("SATsTier") = "ON" then%>
<th ALIGN="LEFT"><b>SATsTier</b></th>
<%end if%>
<%If request.form("TMG3") = "ON" then%>
<th ALIGN="LEFT"><b>TMG3</b></th>
<%end if%>
<%If request.form("TMG3g") = "ON" then%>
<th ALIGN="LEFT"><b>TMG3g</b></th>
<%end if%>
<%If request.form("Msat2") = "ON" then%>
<th ALIGN="LEFT"><b>Msat2</b></th>
<%end if%>
<%If request.form("Esat2") = "ON" then%>
<th ALIGN="LEFT"><b>Esat2</b></th>
<%end if%>
<%If request.form("Ssat2") = "ON" then%>
<th ALIGN="LEFT"><b>Ssat2</b></th>
<%end if%>
<%If request.form("Msat3") = "ON" then%>
<th ALIGN="LEFT"><b>Msat3</b></th>
<%end if%>
<%If request.form("Esat3") = "ON" then%>
<th ALIGN="LEFT"><b>Esat3</b></th>
<%end if%>
<%If request.form("Ssat3") = "ON" then%>
<th ALIGN="LEFT"><b>Ssat3</b></th>
<%end if%>
<%If request.form("KS4TG") = "ON" then%>
<th ALIGN="LEFT"><b>KS4TG</b></th>
<%end if%>
<%If request.form("GCSETier") = "ON" then%>
<th ALIGN="LEFT"><b>GCSETier</b></th>
<%end if%>
<%If request.form("CW1") = "ON" then%>
<th ALIGN="LEFT"><b>CW1</b></th>
<%end if%>
<%If request.form("CW2") = "ON" then%>
<th ALIGN="LEFT"><b>CW2</b></th>
<%end if%>
<%If request.form("CW3") = "ON" then%>
<th ALIGN="LEFT"><b>CW3</b></th>
<%end if%>
<%If request.form("DataCW1") = "ON" then%>
<th ALIGN="LEFT"><b>DataCW1</b></th>
<%end if%>
<%If request.form("DataCW2") = "ON" then%>
<th ALIGN="LEFT"><b>DataCW2</b></th>
<%end if%>
<%If request.form("DataCW3") = "ON" then%>
<th ALIGN="LEFT"><b>DataCW3</b></th>
<%end if%>
</tr>
</thead>
<tbody>
<!--#include file="../../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM Results WHERE (Class = '::Class::')"
fp_sDefault="Class="
fp_sNoRecords="<tr><td colspan=36 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="PupilData"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&ExamNumber=5&Surname=202&Name=202 &Gender=202&Form=202&Year=5&Band=202&Set =5&Class=202&Teacher=202&IEP=202&Yr7TG=202&a mp;Year7=202&Yr8TG=202&Year8=202&YR9TG=202&S AS7=5&SAS9=5&KS3mg=5&SATsTier=202&TMG3=5& ;TMG3g=202&Msat2=5&Esat2=5&Ssat2=5&Msat3=5&a mp;Esat3=5&Ssat3=5&KS4TG=202&GCSETier=202&CW 1=202&CW2=202&CW3=202&DataCW1=202&DataCW2=20 2&DataCW3=202&"
fp_iDisplayCols=36
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../../_fpclass/fpdbrgn1.inc"-->
<tr>

<%If request.form("ExamNumber") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"ExamNumber")%>  </td>
<%end if%>
<td>
<%=FP_FieldVal(fp_rs,"Surname")%>&am p;nbsp;</td>
<td>
<%=FP_FieldVal(fp_rs,"Name")%>&n bsp;</td>

<%If request.form("Gender") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Gender")%>& ;nbsp;</td>
<%end if%>
<%If request.form("Form") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Form")%>&n bsp;</td>
<%end if%>
<%If request.form("Year") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Year")%>&n bsp;</td>
<%end if%>
<%If request.form("Band") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Band")%>&n bsp;</td>
<%end if%>
<%If request.form("Set") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Set")%>&nb sp;</td>
<%end if%>
<%If request.form("Class") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Class")%>& nbsp;</td>
<%end if%>
<%If request.form("Teacher") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Teacher")%>&am p;nbsp;</td>
<%end if%>

<%If request.form("IEP") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"IEP")%>&nb sp;</td>
<%end if%>
<%If request.form("Yr7TG") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Yr7TG")%>& nbsp;</td>
<%end if%>
<%If request.form("Year7") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Year7")%>& nbsp;</td>
<%end if%>
<%If request.form("Yr8TG") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Yr8TG")%>& nbsp;</td>
<%end if%>
<%If request.form("Year8") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Year8")%>& nbsp;</td>
<%end if%>
<%If request.form("YR9TG") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"YR9TG")%>& nbsp;</td>
<%end if%>
<%If request.form("SAS7") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"SAS7")%>&n bsp;</td>
<%end if%>
<%If request.form("SAS9") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"SAS9")%>&n bsp;</td>
<%end if%>
<%If request.form("KS3mg") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"KS3mg")%>& nbsp;</td>
<%end if%>
<%If request.form("SATsTier") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"SATsTier")%>&a mp;nbsp;</td>
<%end if%>
<%If request.form("TMG3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"TMG3")%>&n bsp;</td>
<%end if%>
<%If request.form("TMG3g") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"TMG3g")%>& nbsp;</td>
<%end if%>
<%If request.form("Msat2") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Msat2")%>& nbsp;</td>
<%end if%>
<%If request.form("Esat2") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Esat2")%>& nbsp;</td>
<%end if%>
<%If request.form("Ssat2") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Ssat2")%>& nbsp;</td>
<%end if%>
<%If request.form("Msat3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Msat3")%>& nbsp;</td>
<%end if%>
<%If request.form("Esat3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Esat3")%>& nbsp;</td>
<%end if%>
<%If request.form("Ssat3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Ssat3")%>& nbsp;</td>
<%end if%>
<%If request.form("KS4TG") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"KS4TG")%>& nbsp;</td>
<%end if%>
<%If request.form("GCSETier") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"GCSETier")%>&a mp;nbsp;</td>
<%end if%>
<%If request.form("CW1") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"CW1")%>&nb sp;</td>
<%end if%>
<%If request.form("CW2") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"CW2")%>&nb sp;</td>
<%end if%>
<%If request.form("CW3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"CW3")%>&nb sp;</td>
<%end if%>
<%If request.form("DataCW1") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"DataCW1")%>&am p;nbsp;</td>
<%end if%>
<%If request.form("DataCW2") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"DataCW2")%>&am p;nbsp;</td>
<%end if%>
<%If request.form("DataCW3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"DataCW3")%>&am p;nbsp;</td>
<%end if%>

</tr>
<!--#include file="../../_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>

</body>

</html>
westy

 

Posts: 54
From: UK
Status: offline

 
RE: Sorting columns - 4/28/2004 13:02:27   
Hi
The sort would normally be in the SQL statement . line 1 below from your code page 2.

quote:

<%
fp_sQry="SELECT * FROM Results WHERE (Class = '::Class::')"
fp_sDefault="Class="
fp_sNoRecords="<tr><td colspan=36 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="PupilData"
fp_iMaxRecords=256


And should look something like this.
fp_sQry="SELECT * FROM Results WHERE (Class = '::Class::') ORDER BY ::SortCol:: ASC"

where Sortcol is a variable that you set to the fieldname you want to sort by.
there should be a default for SortCol, otherwise you will get errors.

adjustments to the sort order can be made by creating hyperlinks in the fieldname headers to set SortCol to is heading name.


You will need to ensure when you refresh the page it does not loose all its preset info from your page one.


Hope this helps


Westy

_____________________________

WESTY

(in reply to DesiMcK)
DesiMcK

 

Posts: 446
Joined: 4/26/2004
From: Essex, UK
Status: offline

 
RE: Sorting columns - 4/28/2004 17:29:38   
Thank you. I believe I have the links working but the problem is that the data from the first form is lost. Do you know of a way to solve this problem?

Desi

(in reply to westy)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Sorting columns - 4/28/2004 17:43:19   
This may work. In your form change the method from POST to GET. That will pass the form variables with the querystring. You may however have to change the references to Request.Form on the results page to simply Request or Request.QueryString.

Good luck.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to DesiMcK)
DesiMcK

 

Posts: 446
Joined: 4/26/2004
From: Essex, UK
Status: offline

 
RE: Sorting columns - 4/28/2004 17:55:30   
I have tried requested and request.querystring but I get the same thing. The two static columns appear with no data.

Any other suggestions??

Desi

(in reply to BeTheBall)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Sorting columns - 4/28/2004 18:02:13   
But did you try GET instead of POST?

Try changing this line from your search form:

<form BOTID="0" METHOD="POST" action="SearchByClassResults.asp">

to

<form BOTID="0" METHOD="GET" action="SearchByClassResults.asp">

It may make the querystring too long, but it's worth a try.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to DesiMcK)
DesiMcK

 

Posts: 446
Joined: 4/26/2004
From: Essex, UK
Status: offline

 
RE: Sorting columns - 4/28/2004 18:06:04   
Yes I did that and when I used request.querystring the data appeared. By then when I clicked on one of the column headings in order to sort the data disappeared.

(in reply to BeTheBall)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Sorting columns - 4/28/2004 18:08:52   
Do you have an example of the 'sort' code you have tried?
Its not in the code you have above

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to DesiMcK)
DesiMcK

 

Posts: 446
Joined: 4/26/2004
From: Essex, UK
Status: offline

 
RE: Sorting columns - 4/28/2004 18:10:38   
I used the suggestion in the article I mentioned at the start of this thread. Thanks for your help.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Pupil Data: Search By Class Results</title>
</head>

<body>

<table width="100%" border="1" id="table1">
<thead>
<tr>

<%If request.QueryString("ExamNumber") = "ON" then%>
<th ALIGN="LEFT"><b>ExamNumber</b></th>
<%end if%>

<th ALIGN="LEFT"><b>
<a href="SearchByClassResults_copy(1).asp?SortCol=Surname">Surname</a></b></th>

<th ALIGN="LEFT"><b>
<a href="SearchByClassResults_copy(1).asp?SortCol=Name">Name</a></b></th>

<%If request.QueryString("Address") = "ON" then%>
<th ALIGN="LEFT"><b>Address</b></th>
<%end if%>
<%If request.QueryString("Tel") = "ON" then%>
<th ALIGN="LEFT"><b>Tel</b></th>
<%end if%>


<%If request.QueryString("Gender") = "ON" then%>
<th ALIGN="LEFT"><b>
<a href="SearchByClassResults_copy(1).asp?SortCol=Gender">Gender</a></b></th>
<%end if%>
<%If request.QueryString("Form") = "ON" then%>
<th ALIGN="LEFT"><b>Form</b></th>
<%end if%>
<%If request.QueryString("Year") = "ON" then%>
<th ALIGN="LEFT"><b>Year</b></th>
<%end if%>
<%If request.QueryString("Band") = "ON" then%>
<th ALIGN="LEFT"><b>Band</b></th>
<%end if%>
<%If request.QueryString("Set") = "ON" then%>
<th ALIGN="LEFT"><b>Set</b></th>
<%end if%>
<%If request.QueryString("Class") = "ON" then%>
<th ALIGN="LEFT"><b>Class</b></th>
<%end if%>
<%If request.QueryString("Teacher") = "ON" then%>
<th ALIGN="LEFT"><b>Teacher</b></th>
<%end if%>

<%If request.QueryString("IEP") = "ON" then%>
<th ALIGN="LEFT"><b>IEP</b></th>
<%end if%>
<%If request.QueryString("Yr7TG") = "ON" then%>
<th ALIGN="LEFT"><b>Yr7TG</b></th>
<%end if%>
<%If request.QueryString("Year7") = "ON" then%>
<th ALIGN="LEFT"><b>Year7</b></th>
<%end if%>
<%If request.QueryString("Yr8TG") = "ON" then%>
<th ALIGN="LEFT"><b>Yr8TG</b></th>
<%end if%>
<%If request.QueryString("Year8") = "ON" then%>
<th ALIGN="LEFT"><b>Year8</b></th>
<%end if%>
<%If request.QueryString("Yr9TG") = "ON" then%>
<th ALIGN="LEFT"><b>YR9TG</b></th>
<%end if%>
<%If request.QueryString("SAS7") = "ON" then%>
<th ALIGN="LEFT"><b>SAS7</b></th>
<%end if%>
<%If request.QueryString("SAS9") = "ON" then%>
<th ALIGN="LEFT"><b>SAS9</b></th>
<%end if%>
<%If request.QueryString("KS3mg") = "ON" then%>
<th ALIGN="LEFT"><b>KS3mg</b></th>
<%end if%>
<%If request.QueryString("SATsTier") = "ON" then%>
<th ALIGN="LEFT"><b>SATsTier</b></th>
<%end if%>
<%If request.QueryString("TMG3") = "ON" then%>
<th ALIGN="LEFT"><b>TMG3</b></th>
<%end if%>
<%If request.QueryString("TMG3g") = "ON" then%>
<th ALIGN="LEFT"><b>TMG3g</b></th>
<%end if%>
<%If request.QueryString("Msat2") = "ON" then%>
<th ALIGN="LEFT"><b>Msat2</b></th>
<%end if%>
<%If request.QueryString("Esat2") = "ON" then%>
<th ALIGN="LEFT"><b>Esat2</b></th>
<%end if%>
<%If request.QueryString("Ssat2") = "ON" then%>
<th ALIGN="LEFT"><b>Ssat2</b></th>
<%end if%>
<%If request.QueryString("Msat3") = "ON" then%>
<th ALIGN="LEFT"><b>Msat3</b></th>
<%end if%>
<%If request.QueryString("Esat3") = "ON" then%>
<th ALIGN="LEFT"><b>Esat3</b></th>
<%end if%>
<%If request.QueryString("Ssat3") = "ON" then%>
<th ALIGN="LEFT"><b>Ssat3</b></th>
<%end if%>
<%If request.QueryString("KS4TG") = "ON" then%>
<th ALIGN="LEFT"><b>KS4TG</b></th>
<%end if%>
<%If request.QueryString("GCSETier") = "ON" then%>
<th ALIGN="LEFT"><b>GCSETier</b></th>
<%end if%>
<%If request.QueryString("CW1") = "ON" then%>
<th ALIGN="LEFT"><b>CW1</b></th>
<%end if%>
<%If request.QueryString("CW2") = "ON" then%>
<th ALIGN="LEFT"><b>CW2</b></th>
<%end if%>
<%If request.QueryString("CW3") = "ON" then%>
<th ALIGN="LEFT"><b>CW3</b></th>
<%end if%>
<%If request.QueryString("DataCW1") = "ON" then%>
<th ALIGN="LEFT"><b>DataCW1</b></th>
<%end if%>
<%If request.QueryString("DataCW2") = "ON" then%>
<th ALIGN="LEFT"><b>DataCW2</b></th>
<%end if%>
<%If request.QueryString("DataCW3") = "ON" then%>
<th ALIGN="LEFT"><b>DataCW3</b></th>
<%end if%>
</tr>
</thead>
<tbody>
<!--#include file="../../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM Results WHERE (Class = '::Class::') ORDER BY ::SortCol:: ASC"
fp_sDefault="SortCol=Surname"
fp_sNoRecords="<tr><td colspan=36 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="PupilData"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&ExamNumber=5&Surname=202&Address=202&Tel=202&Name=202&Gender=202&Form=202&Year=5&Band=202&Set=5&Class=202&Teacher=202&IEP=202&Yr7TG=202&Year7=202&Yr8TG=202&Year8=202&YR9TG=202&SAS7=5&SAS9=5&KS3mg=5&SATsTier=202&TMG3=5&TMG3g=202&Msat2=5&Esat2=5&Ssat2=5&Msat3=5&Esat3=5&Ssat3=5&KS4TG=202&GCSETier=202&CW1=202&CW2=202&CW3=202&DataCW1=202&DataCW2=202&DataCW3=202&"
fp_iDisplayCols=36
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../../_fpclass/fpdbrgn1.inc"-->
<tr>

<%If request.QueryString("ExamNumber") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"ExamNumber")%> </td>
<%end if%>
<td>
<%=FP_FieldVal(fp_rs,"Surname")%> </td>
<td>
<%=FP_FieldVal(fp_rs,"Name")%> </td>

<%If request.QueryString("Address") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Address")%> </td>
<%end if%>
<%If request.QueryString("Tel") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Tel")%> </td>
<%end if%>


<%If request.QueryString("Gender") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Gender")%> </td>
<%end if%>
<%If request.QueryString("Form") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Form")%> </td>
<%end if%>
<%If request.QueryString("Year") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Year")%> </td>
<%end if%>
<%If request.QueryString("Band") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Band")%> </td>
<%end if%>
<%If request.QueryString("Set") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Set")%> </td>
<%end if%>
<%If request.QueryString("Class") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Class")%> </td>
<%end if%>
<%If request.QueryString("Teacher") = "ON" then%>
<td>

<%=FP_FieldVal(fp_rs,"Teacher")%> </td>
<%end if%>

<%If request.QueryString("IEP") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"IEP")%> </td>
<%end if%>
<%If request.QueryString("Yr7TG") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Yr7TG")%> </td>
<%end if%>
<%If request.QueryString("Year7") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Year7")%> </td>
<%end if%>
<%If request.QueryString("Yr8TG") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Yr8TG")%> </td>
<%end if%>
<%If request.QueryString("Year8") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Year8")%> </td>
<%end if%>
<%If request.QueryString("YR9TG") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"YR9TG")%> </td>
<%end if%>
<%If request.QueryString("SAS7") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"SAS7")%> </td>
<%end if%>
<%If request.QueryString("SAS9") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"SAS9")%> </td>
<%end if%>
<%If request.QueryString("KS3mg") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"KS3mg")%> </td>
<%end if%>
<%If request.QueryString("SATsTier") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"SATsTier")%> </td>
<%end if%>
<%If request.QueryString("TMG3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"TMG3")%> </td>
<%end if%>
<%If request.QueryString("TMG3g") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"TMG3g")%> </td>
<%end if%>
<%If request.QueryString("Msat2") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Msat2")%> </td>
<%end if%>
<%If request.QueryString("Esat2") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Esat2")%> </td>
<%end if%>
<%If request.QueryString("Ssat2") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Ssat2")%> </td>
<%end if%>
<%If request.QueryString("Msat3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Msat3")%> </td>
<%end if%>
<%If request.QueryString("Esat3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Esat3")%> </td>
<%end if%>
<%If request.QueryString("Ssat3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"Ssat3")%> </td>
<%end if%>
<%If request.QueryString("KS4TG") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"KS4TG")%> </td>
<%end if%>
<%If request.QueryString("GCSETier") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"GCSETier")%> </td>
<%end if%>
<%If request.QueryString("CW1") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"CW1")%> </td>
<%end if%>
<%If request.QueryString("CW2") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"CW2")%> </td>
<%end if%>
<%If request.QueryString("CW3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"CW3")%> </td>
<%end if%>
<%If request.QueryString("DataCW1") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"DataCW1")%> </td>
<%end if%>
<%If request.QueryString("DataCW2") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"DataCW2")%> </td>
<%end if%>
<%If request.QueryString("DataCW3") = "ON" then%>
<td>
<%=FP_FieldVal(fp_rs,"DataCW3")%> </td>
<%end if%>

</tr>
<!--#include file="../../_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>

</body>

</html>

(in reply to Spooky)
BeTheBall

 

Posts: 6381
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Sorting columns - 4/28/2004 18:15:45   
My bad. Failed to realize that when you click a link you will clear the querystring. I'll have to think on it a bit more. Spooky will likely be able to come up with something while I think. He has a faster processor than I. Mine is more of a 386. :)

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to DesiMcK)
DesiMcK

 

Posts: 446
Joined: 4/26/2004
From: Essex, UK
Status: offline

 
RE: Sorting columns - 4/28/2004 18:18:03   
Thank you very much for spending the time helping me. I very much appreciate it.

Desi

(in reply to BeTheBall)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Sorting columns - 4/28/2004 20:24:24   
The issue is that each link needs to maintain the state of the page.
Currently you have :

<a href="SearchByClassResults.asp?SortCol=Name">Name</a>

However, there are also multiple checkboxes passed to the page as well.
EACH one of those needs to be includes in the querystring as well.
When you click the link above, the previous values are lost.

This is how each new link should look :

<a href="SearchByClassResults.asp?SortCol=Name&IEP=<%=request.QueryString("IEP")%>&Yr7TG<%= request.QueryString("Yr7TG")%>">Name</a>

Thats just to start.....you need ALL of the values in each querystring so that the column state is maintained.

Big job..... :)

.

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to DesiMcK)
DesiMcK

 

Posts: 446
Joined: 4/26/2004
From: Essex, UK
Status: offline

 
RE: Sorting columns - 4/29/2004 3:59:31   
Oh dear... in that case would it to possible to choose the order field before the query is sent, ie in the selection form? If this is possible could you explain how?
Thanks,

Desi

(in reply to Spooky)
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Sorting columns - 4/29/2004 5:37:54   
Yes a lot easier ;-)
Just add a drop down list called "SortCol" with the actual column names on the first page.

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to DesiMcK)
DesiMcK

 

Posts: 446
Joined: 4/26/2004
From: Essex, UK
Status: offline

 
RE: Sorting columns - 4/29/2004 7:59:41   
Thanks for the advice. I added a combo box with the column names and I named the combo box SortCol.

I then inserted this line of code into the results page but it seems to be wrong.

fp_sQry="SELECT * FROM Results ORDER BY request.form("SortCol") ASC WHERE (Class = '::Class::') "

Have I made an obvious error.

Thanks,

Desi

(in reply to Spooky)
westy

 

Posts: 54
From: UK
Status: offline

 
RE: Sorting columns - 4/29/2004 8:05:54   
Hi

normally the orderby is at the end of the sql statement.

i am not sure if the SQl will understand the request.form("sortCol")

You could try putting the SQL back as it wos and adding a line near the top

SortCol = request.form("SortCol")



Westy

_____________________________

WESTY

(in reply to DesiMcK)
DesiMcK

 

Posts: 446
Joined: 4/26/2004
From: Essex, UK
Status: offline

 
RE: Sorting columns - 4/29/2004 9:03:23   
OK. I tried this and I recieve an error says too few parameters. Here is my code

sortcol=request.form("SortCol")
fp_sQry="SELECT * FROM Results WHERE (Class = '::Class::') ORDER BY sortcol"

Thanks for your help,

Desi

(in reply to westy)
westy

 

Posts: 54
From: UK
Status: offline

 
RE: Sorting columns - 4/29/2004 9:09:05   
Hi

try replacing

quote:

sortcol=request.form("SortCol")
fp_sQry="SELECT * FROM Results WHERE (Class = '::Class::') ORDER BY sortcol"


with your old code

fp_sQry="SELECT * FROM Results WHERE (Class = '::Class::') ORDER BY ::SortCol:: ASC"


Westy:)

_____________________________

WESTY

(in reply to DesiMcK)
DesiMcK

 

Posts: 446
Joined: 4/26/2004
From: Essex, UK
Status: offline

 
RE: Sorting columns - 4/29/2004 9:17:51   
Thank you that works brillantly.

Big thanks to everone who helped.

Desi

(in reply to westy)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Sorting columns
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts