Volunteer Opportunity Search
* Search our database for local or virtual volunteer opportunities that match your service preference.
* Enter your zip code and distance you're willing to travel, or search for virtual opportunities only.
* Thank you for volunteering!
<%
sub createsql()
If (dLatitude <> 0 or dLongitude <> 0) and Request.Form("chkVirtual")= "on" then
strsql =strSQL & " AND (Opportunities.Zip IN ( SELECT Zip FROM CityStateZip " _
& "WHERE " & Miles & " > 3959 * ACOS(SIN(" & dLatitude & "/ 57.3) * SIN(Latitude/ 57.3) + " _
& "COS(" & dLatitude & "/ 57.3) * COS(Latitude/ 57.3) * " _
& "COS((Longitude/ 57.3) - (" & dLongitude & "/ 57.3)))) or Opportunities.VirtualOpp=1 )"
exit sub
end if
If dLatitude <> 0 or dLongitude <> 0 then ' Request.Form("chkVirtual") <> "on" Then
strSQL = strSQL & " AND (Opportunities.Zip IN ( SELECT Zip FROM CityStateZip " _
& "WHERE " & Miles & " > 3959 * ACOS(SIN(" & dLatitude & "/ 57.3) * SIN(Latitude/ 57.3) + " _
& "COS(" & dLatitude & "/ 57.3) * COS(Latitude/ 57.3) * " _
& "COS((Longitude/ 57.3) - (" & dLongitude & "/ 57.3))))) "
Else
If Request.Form("chkVirtual") = "on" Then
strSQL = strSQL & " AND Opportunities.VirtualOpp=1 "
end if
end If
end sub
dim strsql1
If Ucase(Request.QueryString("Search")) = "TRUE" and (Zip <> "" or Virtual <> "") Then
'Get the longitude and latitude of their zip code
Set RecSet = Server.CreateObject("ADODB.Recordset")
if Zip<>"" then
RecSet.Open "SELECT Latitude, Longitude FROM CityStateZip WHERE Zip='" & Zip & "'", dbConnection
If Not RecSet.EOF Then
dLatitude = RecSet("Latitude")
dLongitude = RecSet("Longitude")
RecSet.Close
Set RecSet = Nothing
end if
end if
'Make sure we have coordinates for the Zip Code
If (dLatitude = 0 or dLongitude = 0) and Request.Form("chkVirtual") <> "on" Then
Response.Write "
Zip Code Does Not Exist
"
Else
'Generate the SQL statement
Set RecSet = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT DISTINCT NonProfits.Zip, NonProfits.OrgName, Opportunities.OpportunityID, Opportunities.VirtualOpp, Opportunities.OpportunityName, Opportunities.StartDate, Opportunities.EndDate, Opportunities.UserID " _
& "FROM (NonProfits INNER JOIN Opportunities ON NonProfits.UserID = Opportunities.UserID) LEFT JOIN UserServiceTypeJoin ON NonProfits.UserID = UserServiceTypeJoin.UserID " _
& "WHERE (EndDate >= getdate() OR Opportunities.OngoingOpp = 1) "
call createsql()
If types = "29" then
strSQL = strSQL & "AND UserServiceTypeJoin.ServiceTypeID IN (select servicetypeid from servicetypes)"
else
if types<>"" then
strSQL = strSQL & "AND UserServiceTypeJoin.ServiceTypeID IN (" & Types & ")"
end if
End If
strSQL = strSQL & ";"
'response.write strSQL
RecSet.CursorLocation=3
RecSet.Open strSQL, dbConnection, 3 '3=adOpenStatic
RecSet.PageSize = 25
'Display the search results
If RecSet.EOF Then
Response.Write "
No Matching Opportunities Found
"
Else
RecSet.AbsolutePage = intCurrentPage
intTotalPages = RecSet.PageCount
intCurrentRecord = RecSet.AbsolutePosition
intTotalRecords = RecSet.RecordCount
Response.Write "
" & intTotalRecords & " matching opportunities found
"
For i = intCurrentRecord To intCurrentRecord + RecSet.PageSize - 1 'display from the current record to the pagesize
If Not RecSet.EOF Then %>
<% RecSet.MoveNext
End if
Next
'Display Page Navigation
Select Case Cint(intCurrentPage)
Case Cint(intTotalPages) 'If its the last page give only links to Move First and Move Previous
If Cint(intTotalPages) = 1 Then
strMoveNext = "
Next >"
strMovePrevious = "< Prev"
Else
strMoveNext = "
Next >"
strMovePrevious = "
< Prev"
End If
Case 1 'if its the first page only give links To move Next and move last
strMoveNext = "
Next >"
strMovePrevious = "
< Prev"
Case Else
strMoveNext = "
Next >"
strMovePrevious = "
< Prev"
End Select %>
|
<%=strMovePrevious%>
|
Page <%=intCurrentPage & " of " & intTotalPages%>
|
<%=strMoveNext%>
|
<%
End If
RecSet.Close
Set RecSet = Nothing
end if
End If
%>
<%
dbConnection.Close
Set dbConnection = Nothing
%>