%
pcode = 0
If Request("location") <> "" Then
session("county") = Request("location")
ElseIf Request("county") <> "" Then
session("county") = Request("location")
End If
If request("sql") = "" Then
sql = "SELECT ID, Name, Town, Category FROM Golf WHERE "
If request("postcode") <> "" Then
sql= sql & "((Postcode LIKE '%" & Request("pstcode") & "%') Or (Postcode = '" & Request("postcode") & "')) And not(ID =" & Request("ID") & ")"
pcode = 1
ElseIf request("name") <> "" Then
sql = sql & " Name Like '%" & request("name") & "%'"
ElseIf request("category") = "All" And request("holes") = "All" Then
sql = sql & "((County = '" & Request("location") & "') Or (Town = '" & Request("location") & "')) "
ElseIf request("category") <> "All" And request("holes") <> "All" Then
sql = sql & "((County = '" & Request("location") & "') Or (Town = '" & Request("location") & "')) And Category = '" & Request("Category") & "' And Holes Like '%" & Request("holes") & "%'"
ElseIf request("category") <> "All" And request("holes") = "All" Then
sql = sql & "((County = '" & Request("location") & "') Or (Town = '" & Request("location") & "')) And Category = '" & Request("Category") & "'"
ElseIf request("holes") <> "All" And request("category") = "All" Then
sql = sql & "((County = '" & Request("location") & "') Or (Town = '" & Request("location") & "')) And Holes Like '%" & Request("holes") & "%'"
Else
sql = sql & "((County = '" & Request("location") & "') Or (Town = '" & Request("location") & "')) "
End If
sql = sql & " Order By Town, Name"
Else
sql=request("sql")
End If
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
Conn.Open "dsn=NITB;uid=Guest"
RS.Open sql, Conn, adOpenKeyset,adLockReadOnly
If pcode = 1 And RS.EOF Then
If Right(Request("pstcode"),(Len(Request("pstcode"))-2)) <= 17 Then
Conn.Close
set rs = nothing
set Conn = nothing
sql = "SELECT ID, Name, Town, Category FROM Golf WHERE "
sql= sql & " Town = 'Belfast' And not(ID =" & Request("ID") & ")"
sql = sql & " Order By Town, Name"
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
Conn.Open "dsn=NITB;uid=Guest"
RS.Open sql, Conn, adOpenKeyset,adLockReadOnly
session("msg") = "No golf courses where found in the immediate area
however these where found within Belfast"
Else
Conn.Close
set rs = nothing
set Conn = nothing
sql = "SELECT ID, Name, Town, Category FROM Golf WHERE "
sql= sql & " County = '" & request("county") & "' And not(ID =" & Request("ID") & ")"
sql = sql & " Order By Town, Name"
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
Conn.Open "dsn=NITB;uid=Guest"
RS.Open sql, Conn, adOpenKeyset,adLockReadOnly
session("msg") = "No golf courses where found in the immediate area
however these where found within the same county"
End If
End If
%>
<% If not RS.EOF Then %>
<%
count = RS.RecordCount / 7
if rs.recordcount/7-(int(rs.recordcount/7))>0 then
count=count+1
end if
count=int(count)
RS.PageSize = 7 ' Number of rows per page
if Request("Action") = "" Then
FormAction = "SearchGolf.asp"
else
Response.Redirect("GolfForm.asp?sql=" & Server.URLEncode(sql))
end if
ScrollAction = Request("ScrollAction")
if ScrollAction <> "" Then
PageNo = mid(ScrollAction, 5)
if PageNo < 1 Then
PageNo = 1
end if
else
PageNo = 1
end if
RS.AbsolutePage = PageNo
%>
<% If session("msg") <> "" Then %>
<% = session("msg")%> <% session("msg") = "" %> <% End If %> | Page <%=PageNo%> of <% = count %> |