Join us on Facebook!
28
Feb

Alphabetic Database Display

by admin 1150 views 0 Comments and 0 Rections

Alphabetic navigation of a database provides a unique way to display just about data. A simple for next loop generates all of the alphabetic hyperlinks into the database and an sql statement targeted to the first letter in the targeted field allows for alphabetic displaying of data. Utilizing our database with all fifty states in it we will hyperlink the letters A-Z and based on that input search the data for all states that begin with the letter the user clicked on.

  
Alphabetic Database Display

<%
for counter = 65 to 90
' for next routine to create hyperlinks alphabetically targeted
' to the current page
%>
?u_letter=&#<%= counter %>;">
&#<%= counter %>;

<% next %>



<%
u_letter=trim(request.querystring("u_letter"))
'if the user clicked a link then search the db
if u_letter<>"" then
accessdb="state_info"
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
Set rs = Server.CreateObject("ADODB.Recordset")

sql = "select * from states where left(statename,1)='"& u_letter &"' order by statename asc"

rs.Open sql, cn
'if the search ends in no results display a
'no results found mesage
if rs.eof then
%>
No states begin with the letter <%= u_letter %>
<% else
do while not rs.eof
'display all observations found
%>


<%= rs("statename") %>
<%
rs.movenext
loop
end if ' end check for obs
end if ' end check for user input
%>

More Posts in "Tutorials"

Comments

blog comments powered by Disqus

Feed Subscription

Get daily inboxed with latest news, reviews and tutorials. Signup now it's free :)



Planetmaks on Twitter

Follow PlanetMaks on Facebook

Recent Comments

Powered by Disqus

Tags

32Bit 64Bit 7 Admin Tool Admin Tools Admin-Tool Admin-Tools AdminTool Adobe Adware All-in-One Anti-Spyware Anti-Virus Apple Backup Tools Browser Browsers Changing Default Directory Codec Data Recovery Download Manager Downloads Drive Utilities Driver Drivers Firefox Flash Freeware Google Graphics Internet Tool Internet-Tool Messaging Microsoft Microsoft Tool Micsellonous Monitoring Multimedia Networking News NVidia Office Tool Office-Tool PC Suite Press Release Registry Samsung Security Shareware Software Softwares Tutorials Vista Windows Windows 7 Windows 8