%@ LANGUAGE=VBScript %>
<%
Response.Buffer = True
Dim connect, recordset, whereclause, query, delQuery, key, itemNumber
Dim lineIndex, begin_search, preOrder, asapSB, ASCDESC, fullOrderBy
Dim pageNumber, uniqueID, newID, asapIfr, prefix, suffix, resultLink, editResultLink
'below gets the ascending / descending going
'below is for the first time
If Session("ASCDESC_adult_1630") = "" Then
ASCDESC = " ASC"
Session("ASCDESC_adult_1630") = ASCDESC
Else
'below is if session is set and we have clicked on a heading
If Request("asapSB") <> "" Then
If Request("asapSB") = Session("asapSB_adult_1630") Then
' below is if we have clicked on the same heading
If Session("ASCDESC_adult_1630") = " ASC" Then
ASCDESC = " DESC"
Else
ASCDESC = " ASC"
End If
Session("ASCDESC_adult_1630") = ASCDESC
Else
' below is if we have clicked on a different heading
ASCDESC = " ASC"
Session("ASCDESC_adult_1630") = ASCDESC
End If
Else
ASCDESC = Session("ASCDESC_adult_1630")
End If
End If
If ASCDESC = " ASC" Then
asapWD = "▼"
Else
asapWD = "▲"
End If
' below gets the sortby going
If Request("asapSB") <> "" Then
asapSB = Request("asapSB")
Session("asapSB_adult_1630") = asapSB
Else
If Session("asapSB_adult_1630") = "" Then
asapSB = "Facility"
Session("asapSB_adult_1630") = asapSB
Else
asapSB = Session("asapSB_adult_1630")
End If
End If
'functions for searches
Dim arrSearch, selCrit, strCombine, strInput
'This Sub Sets the SQL string to search for the exact phrase
Sub Exact(whereclause,fieldname,strInput)
whereclause = whereclause & " (" & fieldname & " LIKE '"
whereclause = whereclause & strInput & "') AND "
End Sub
'This sub searches for keyword matches based on selCrit (AND, OR)
Sub Keywrd(whereclause,fieldname,strInput)
arrSearch = split(strInput, " ")
strCombine = join(arrSearch, "%') " & selCrit & " (" & fieldname & " LIKE '%")
whereclause = whereclause & " (" & fieldname & " LIKE '%" & strCombine & "%') AND "
End Sub
'end functions for searches
uniqueID = "adult_1630"
If Session("uniqueID_adult_1630") = "" Then
Session("uniqueID_adult_1630") = uniqueID
newID = 1
End If
If Session("uniqueID_adult_1630") <> uniqueID Then
Session("uniqueID_adult_1630") = uniqueID
newID = 1
End If
preOrder = " ORDER BY adult."
' iframe stuff here ------------------------------
asapIfr = Request("asapIfr")
If asapIfr <> "" Then
Session("asapIfr_adult_1630") = asapIfr
End If
If Session("asapIfr_adult_1630") <> "" Then
asapIfr = Session("asapIfr_adult_1630")
End If
lineIndex = 0
Dim Services
Dim allRecords
Dim asapPages
Dim asapChapters
Dim asapChapter
Dim URL
Dim start10
Dim stop10
Dim next1
Dim previous1
Dim Nextbutton
Dim Previousbutton
Dim nexturl
Dim previousurl
Dim NoResults
%>
<%
pageNumber = CInt(Request("pageNumber"))
If PageNumber = 0 then
pageNumber = 1
End If
' Get the form information in local variables
Services = Trim(Request("Services"))
Services = Replace(Services, "'", "''")
If Services <> "" Then
newID = 1
End If
If newID = 1 Then
begin_search = 1
Else
begin_search = Request("begin_search")
End If
If begin_search = 1 Then
fullOrderBy = " ORDER BY adult.Facility"
Session("fullOrderBy_adult_1630") = fullOrderBy
whereclause = "WHERE "
If Services <> "" Then
selCrit = Request.form("selCrit_Services") 'setting the search criteria "AND", "OR", "ALL"
strInput = Services
if selCrit <> "ALL" then
Call Keywrd(whereclause,"Services",strInput)
else
Call Exact(whereclause,"Services",strInput)
end if
End If
If Right(whereclause, 4) = "AND " Then
whereclause = Left(whereclause, Len(whereclause) - 4) ' strip off 'AND '
Else
whereclause = Left(whereclause, Len(whereclause) - 6) ' strip off 'WHERE '
End If
query = "SELECT * FROM adult " & whereclause
Session("SSS_query_adult_1630") = query
End If
If Session("SSS_query_adult_1630") = "" Then
fullOrderBy = " ORDER BY adult.Facility"
Session("fullOrderBy_adult_1630") = fullOrderBy
query = " SELECT * FROM adult " & whereclause
Session("SSS_query_adult_1630") = query
query = query + fullOrderBy
Else
If asapSB = "" Then
fullOrderBy = Session("fullOrderBy_adult_1630")
query = Session("SSS_query_adult_1630") + fullOrderBy
Else
fullOrderBy = preOrder + asapSB + ASCDESC
Session("fullOrderBy_adult_1630") = fullOrderBy
query = Session("SSS_query_adult_1630") + fullOrderBy
End If
End If
set recordset = Server.CreateObject("ADODB.Recordset")
recordset.CursorType = 3 ' adOpenStatic
recordset.PageSize = 90
recordset.Open query, connect
if not recordset.eof then
recordset.AbsolutePage = CInt(pageNumber)
end if
allRecords = recordset.RecordCount
Session("allRecords_adult_1630") = allRecords
asapPages = (allRecords / 90)
%>
directory Search Results
<%
If asapIfr = "" Then
prefix = "location.href='"
suffix = "'"
%>
<%
Else
prefix = "javascript:newWindow('"
suffix = "')"
End If
%>
<% If asapSB = "Facility" Then %>
<%=asapWD%>
<% End If %>
Facility
<% If asapSB = "City" Then %>
<%=asapWD%>
<% End If %>
City
<%
NoResults = True
itemNumber = 0
Do While Not recordset.EOF and itemNumber < recordset.PageSize
NoResults = False
resultLink = prefix + "directory_detail.asp?key=" + Cstr(recordset("ID")) + "&itemNumber=" + Cstr((CInt(pageNumber) - 1) * recordset.PageSize + itemNumber) + suffix
If lineIndex MOD 2 = 0 Then
%>
<%=recordset("Facility")%>
<%=recordset("City")%>
<%
Else
%>
<%=recordset("Facility")%>
<%=recordset("City")%>
<%
End If
itemNumber = itemNumber + 1
lineIndex = lineIndex + 1
recordset.MoveNext
Loop
%>
<%
if NoResults = True Then
%>
Sorry, no records in the database matched your search parameters. Click Back and try again.
<%
End If ' No match
%>
<%
' total of pages
If asapPages - Int(asapPages) > 0 Then
asapPages = Int(asapPages) + 1
End If
' this is the total number of chapters holding the pages
asapChapters = asapPages / 10
If asapChapters - Int(asapChapters) > 0 Then
asapChapters = Int(asapChapters) + 1
End If
' this is the current chapter
asapChapter = pageNumber * .1
If asapChapter = 0 Then
asapChapter = 1
End If
If asapChapter - Int(asapChapter) > 0 Then
asapChapter = Int(asapChapter) + 1
End If
' this would be the first page in the current chapter
start10 = (asapChapter * 10) - 9
' this would be the last page in the current chapter
stop10 = asapChapter * 10
If stop10 > asapPages Then
stop10 = asapPages
End If
next1 = stop10 + 1
previous1 = start10 - 1
Nextbutton = "directory_search_results.asp?pageNumber=" + CStr(next1)
Previousbutton = "directory_search_results.asp?pageNumber=" + CStr(previous1)
%>
<%
End If
' loops through entire range of numbers
For i = start10 to stop10
URL = "directory_search_results.asp?pageNumber=" + CStr(i)
If i = pageNumber Then
%>