<%
'============================================================================
' Action : New Code - Rewrite of new functionality
' Company : Seniorboys
' Contact Info : www.seniorboys.com - 01708 857931
' Author : Kenny Oduyeye
' Description : New functionality used in retrieving
' data entered by user into the Name, Postcode and
' County fields. Search criteria uses wildcard search
' for minimum criteria entered.
' Date : March 2003
'============================================================================
'===============================================
'Kenny Oduyeye - Addition of new code March 2003
'===============================================
Dim myConstring
myConstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "\my_db\praiselink.mdb;"
Dim ors1, strSql
strArea = Request("area")
'strPage = Cint(Request.querystring("page"))
'Set how many records we want per page
'=====================================
Const NumPerPage = 6
'Retrieve what page we are currently on
'======================================
If Request.QueryString("curpage") = "" Then
curpage = 1
Else
curpage = Request.QueryString("curpage")
End If
Dim strName, strPcode, strCounty
strName = Request("church")
strPcode = Request("pcode")
strCounty = Request("county")
if strName <> "" then
strSql = "Status = 'publish' And ChurchName like" + chr(39) + trim(strName) + "%" + chr(39)
strurl = "&church=" & trim(strName)
elseif strPcode <> "" then
strSql = "Status = 'publish' And Postalcode like" + chr(39) + trim(strPcode) + "%" + chr(39)
strUrl = "&pcode=" & trim(strPcode)
elseif strCounty <> "" then
strSql = "Status = 'publish' And city like" + chr(39) + trim(strCounty) + "%" + chr(39)
strUrl = "&county=" & trim(strCounty)
elseif strArea <> "" then
strSql = "areacode =" + chr(39) + trim(strArea) + chr(39)
strUrl = "&area=" & trim(strArea)
else
strSql = ""
end if
'=================================================
'End Of New Added Code - Kenny Oduyeye March 2003
'=================================================
'=========================================================================
'Code below commented out by Kenny Oduyeye - March 2003 New criteria added
'=========================================================================
'strCity = Request("txtcity")
'strArea = Request("area")
'strPage = Cint(Request.querystring("page"))
'myConstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "\my_db\praiselink.mdb;"
'if strCity <> "" then
'strSql = "city like" + chr(39) + trim(strCity) + "%" + chr(39)
'strurl = "&city=" & trim(strCity)
'elseif strArea <> "" then
'strSql = "areacode =" + chr(39) + trim(strArea) + chr(39)
'strUrl = "&area=" & trim(strArea)
'else
' strSql = ""
'end if
'======================================================
'End of Commented out code - Kenny Oduyeye - March 2003
'======================================================
set oRs2 = Server.CreateObject("ADODB.Recordset")
oRs2.ActiveConnection = myConstring
'Kenny Oduyeye - March 2003 : Commented out line of old code
'===========================================================
'oRs2.Source = "SELECT Distinct City FROM churches where city is not null order by city"
'End of code Kenny Oduyeye
'=========================
'Kenny Oduyeye - March 2003 : Inserted new Query to allow minimum search criteria
'================================================================================
oRs2.Source = "SELECT Distinct ChurchName FROM churches where ChurchName is not null and ChurchName like '" & strName & "%' order by ChurchName"
'End of new Query Kenny Oduyeye
'=============================
oRs2.CursorType = 0
oRs2.CursorLocation = 2
oRs2.LockType = 3
oRs2.Open
oRs2_numRows = 0
%>
|
|
<%
if strSql <> "" then
set oRs1 = Server.CreateObject("ADODB.Recordset")
oRs1.ActiveConnection = myconstring
'Set the cursor location property
'================================
oRs1.CursorLocation = adUseClient
'Set the cache size to the number of records per page
'====================================================
oRs1.CacheSize = NumPerPage
'Open our recordset
'==================
oRs1.Source = "SELECT ChurchName, AddressLine1, AddressLine2, City, PostalCode, Website, EmailAddress, Telephone, Fascimille, WorshipType, Title, FirstName, LastName, AreaCode, midweekservice, timeofservice, weekendservice, pastor FROM churches WHERE " + strsql + " ORDER BY ChurchName ASC"
oRs1.Open
If Not oRs1.EOF Then
oRs1.MoveFirst
oRs1.PageSize = NumPerPage
'Get maximum number of pages
'===========================
Dim TotalPages
TotalPages = oRs1.PageCount
'Set the absolute page
'=====================
oRs1.AbsolutePage = CurPage
'Counting variable for our recordset
'===================================
Dim Count
'Set Count equal to zero
'=======================
Count = 0
Dim Repeat1__numRows
Repeat1__numRows = 6
Dim Repeat1__index
Repeat1__index = 0
oRs1_numRows = oRs1_numRows + Repeat1__numRows
If Not oRs1.EOF And Count < oRs1.PageSize Then
%>
| Churches |
<%
End If
%>
<%
Do while Not oRs1.EOF And Count < oRs1.PageSize
IF (Repeat1__numRows MOD 2) <> 0 THEN
Response.write ""
else
Response.Write " | "
end if
%>
<%
if ors1.Fields.Item("midweekservice").Value = "N/A" Or ors1.Fields.Item("timeofservice").Value = "N/A" Or ors1.Fields.Item("weekendservice").Value = "N/A" Or ors1.Fields.Item("Telephone").Value = "N/A" or ors1.Fields.Item("Pastor").Value = "N/A" or ors1.Fields.Item("website").Value = "N/A" Or ors1.Fields.Item("emailaddress").Value = "N/A" then
%>
<%=(oRs1.Fields.Item("ChurchName").Value)%>
<%
Else
%>
','<%=(oRs1.Fields.Item("Timeofservice").Value)%>','<%=(oRs1.Fields.Item("weekendservice").Value)%>','<%=(oRs1.Fields.Item("Telephone").Value)%>','<%=(oRs1.Fields.Item("Pastor").Value)%>','http://<%=(oRs1.Fields.Item("Website").Value)%>','<%=(oRs1.Fields.Item("Emailaddress").Value)%>')"><%=(oRs1.Fields.Item("ChurchName").Value)%>*[more]
<%
End If
%>
<%=(oRs1.Fields.Item("AddressLine1").Value)%>
<%=(oRs1.Fields.Item("AddressLine2").Value)%>
<%=(oRs1.Fields.Item("City").Value)%>
<%=(oRs1.Fields.Item("PostalCode").Value)%>
<%
IF (Repeat1__numRows MOD 2) <> 0 THEN
%>
|
|
<%
end if
Repeat1__index = Repeat1__index + 1
Repeat1__numRows = Repeat1__numRows - 1
Count = Count + 1
oRs1.MoveNext
Loop
%>
| Results:
<%
'Print out the current page # / total pages
'==========================================
Response.Write("" & "Page " & CurPage & " of " & TotalPages & " ")
'Display Next and Previous Buttons
'=================================
If CurPage > 1 Then
'We are not at the begining, show the previous button
'====================================================
Response.Write "<<- Prev "
End If
If CInt(CurPage) <> CInt(TotalPages) Then
'We are not at the end, show the next button
'===========================================
Response.Write "Next ->> "
End If
%>
|
<%
End if
End If
%>
|
|
|