<% 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 %> Results of Golf Search background="/activity/images/golfback.jpg">

Results of <% If request("category") <> "All" Then Response.Write request("category") %> Golf Search

<% If session("msg") <> "" Then %> <% = session("msg")%>

<% session("msg") = "" %> <% End If %>

Page <%=PageNo%>
of <% = count %>
<% Do while not (RS is nothing) %> <% RowCount = rs.PageSize Do While Not RS.EOF and rowcount > 0 %> <% For i = 1 to RS.Fields.Count - 1 %> <% Next %> <% RowCount = RowCount - 1 RS.MoveNext Loop %>
Name Town Category
<% If RS(i).Name = "Name" Then Response.Write "" & RS(i) & "" Else ' Note: The following is a bit of a hack...If the column name contains ' the string "URL" anywhere in it, assume it is a URL to a gif or jpg ' file and generate the HTML to get the image and display. This works ' for the Products table in the Adventure Works database, but is not a ' general purpose solution. If InStr(RS(i).Name, "URL") > 0 Then Response.Write "" Else Response.Write RS(i) End If End If %>

<% set RS = RS.NextRecordSet Loop Conn.Close set rs = nothing set Conn = nothing %> <% Else session("msg") = "No Records Found, please try another search" Response.Redirect("GolfForm.asp") End IF %>

<% if PageNo > 1 Then %> "> <% end if %> <% if RowCount = 0 Then %> "> <% end if %> <% if pcode <> 1 Then %> <% end if %>