Hi Folks,
A couple of you guys asked me a copy of the script which would allow an alphabetical listing of surnames (it couls be anything) from a recordset. Well I have pasted it in below for your enjoyment. Note that it is basically some modified ASP but if you are familiar with the code generated by UD during recordset set up and can navigate through it, it is quite a cool little script.
<%
for counter = 65 to 90
' for next routine to create hyperlinks alphabetically targeted
' to the current page
%>
<a href="<%= request.servervariables("script_name"
%>?u_letter=&#<%= counter %>;">
&#<%= counter %>;</a>
<% next %>
</p>
<p> </p>
<p>
<%
u_letter=trim(request.querystring("u_letter"
)
'if the user clicked a link then search the db
if u_letter<>"" then
accessdb="lifescience"
cn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("database.mdb"
& ";"
Set rs = Server.CreateObject("ADODB.Recordset"
sql = "select * from tblStaff where left(stfSurname,1)='"& u_letter &"' order by stfSurname asc"
rs.Open sql, cn
'if the search ends in no results display a
'no results found mesage
if rs.eof then
%>
No Staff begin with the letter <%= u_letter %>
<% else
do while not rs.eof
'display all observations found
%>
<br>
<%= rs("stfSurname"
%>
<%
rs.movenext
loop
end if ' end check for obs
end if ' end check for user input
%>
This is not one of my scripts, I happened across it in a FAQ section of and ASP site, if I can remember who initiated it I'll credit them at a later date
Have fun.
M
(Mod. Sorry for the length!
)
A couple of you guys asked me a copy of the script which would allow an alphabetical listing of surnames (it couls be anything) from a recordset. Well I have pasted it in below for your enjoyment. Note that it is basically some modified ASP but if you are familiar with the code generated by UD during recordset set up and can navigate through it, it is quite a cool little script.
<%
for counter = 65 to 90
' for next routine to create hyperlinks alphabetically targeted
' to the current page
%>
<a href="<%= request.servervariables("script_name"

&#<%= counter %>;</a>
<% next %>
</p>
<p> </p>
<p>
<%
u_letter=trim(request.querystring("u_letter"

'if the user clicked a link then search the db
if u_letter<>"" then
accessdb="lifescience"
cn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("database.mdb"

Set rs = Server.CreateObject("ADODB.Recordset"

sql = "select * from tblStaff where left(stfSurname,1)='"& u_letter &"' order by stfSurname asc"
rs.Open sql, cn
'if the search ends in no results display a
'no results found mesage
if rs.eof then
%>
No Staff begin with the letter <%= u_letter %>
<% else
do while not rs.eof
'display all observations found
%>
<br>
<%= rs("stfSurname"

<%
rs.movenext
loop
end if ' end check for obs
end if ' end check for user input
%>
This is not one of my scripts, I happened across it in a FAQ section of and ASP site, if I can remember who initiated it I'll credit them at a later date
Have fun.
M
(Mod. Sorry for the length!
