<%
'============================================================================
' Action : New code/functionality
' Company : Seniorboys
' Contact Info : www.seniorboys.com - 01708 857931
' Author : Kenny Oduyeye
' Description : Added new local variables used in retrieving
' data entered by user into the Name, Business Type and
' City fields. Search criteria uses wildcard search
' for minimum criteria entered.
' Date : March 2003
'============================================================================
Dim myConstring
myConstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "\my_db\praiselink.mdb;"
'Set how many records we want per page
'=====================================
Const NumPerPage = 6
'Retrieve what page we are currently on
'======================================
Dim curPage
If Request.QueryString("curpage") = "" Then
curpage = 1
Else
curpage = Request.QueryString("curpage")
End If
Dim oRs1, strSql, strName, strCategory, strCity
strName = Request("name") 'Kenny Oduyeye - New local variables declared March 2003
strCategory = Request("category") 'Kenny Oduyeye - New local variables declared March 2003
strCity = Request("city") 'Kenny Oduyeye - New local variables declared March 2003
'==========================================================
'Kenny Oduyeye March 2003 - Addition of new search criteria
'If Name, Category or City is entered, set query criteria
'==========================================================
if strName <> "" then
strSql = "Status = 'publish' And BusinessName like" + chr(39) + trim(strName) + "%" + chr(39)
strurl = "&name=" & trim(strName)
elseif strCategory <> "" then
strSql = "Status = 'publish' And Category like" + chr(39) + trim(strCategory) + "%" + chr(39)
strUrl = "&category=" & trim(strCategory)
elseif strCity <> "" then
strSql = "Status = 'publish' And City like" + chr(39) + trim(strCity) + "%" + chr(39)
strUrl = "&city=" & trim(strCity)
else
strSql = ""
end if
'==========================================
'Kenny Oduyeye March 2003 - End Of New code
'==========================================
%>
|
|
Search for Businesses by Name/Type/County
|
<%
if strName <> "" Or strCategory <> "" Or strCity <> "" 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 businessname, businessaddress1, businessaddress2, city, postalcode, telephone, category, firstname, website, emailaddress FROM business_listings WHERE " + strsql + " ORDER BY BusinessName 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
%>
| Businesses |
<%
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
%>
<%=(oRs1.Fields.Item("Businessname").Value)%>
<%=(oRs1.Fields.Item("BusinessAddress1").Value)%>
<%=(oRs1.Fields.Item("BusinessAddress2").Value)%>
<%=(oRs1.Fields.Item("City").Value)%>
<%=(oRs1.Fields.Item("PostalCode").Value)%>
Telephone: <%=(oRs1.Fields.Item("Telephone").Value)%>
Business Type: <%=(oRs1.Fields.Item("Category").Value)%>
Contact Name: <%=(oRs1.Fields.Item("Firstname").Value)%>
Website: ')"><%=(oRs1.Fields.Item("Website").Value)%>
Email: "><%=(oRs1.Fields.Item("Emailaddress").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
%>
|
|