Search results
 
<% ' First take care that the entry is correct or return the errors! '------------------------------------------------------------------------------------------------------ 'In case someone is using the old NameCache parameter if len(Request("NameCache"))>0 then paraname="NameCache" elseif len(Request("taxon"))>0 then paraname="taxon" else paraname="name" end if ' Allow multiples items to be search errorcode=0 sql_or="" for each name in Request(paraname) 'Add * to the end if not existing if right(name,1) <> "*" then name=name & "*" end if 'replace characters name=Replace(name, "*", "%") name=Replace(name, "+", " ") name=Replace(name, "'", "''") name=Replace(name, " ", " ") name2=Left(name, InStr(name," ")) + Replace(name, " ", " % ", InStr(name," ")+1) sql_or=sql_or & "(Name.NameCache LIKE '"& name &"') OR (Name.NameCache LIKE '"& name2 &"') OR " 'Error handling if Instr(name,"%") > 0 and Len(name) < 4 then errorcode=1 end if if Instr(name,"%%") > 0 then errorcode=2 end if if Mid(name,1,1) = "%" and Mid(name,4,1) = "%" then errorcode=3 end if if len(name)<3 then errorcode=4 end if Next if len(sql_or)<4 then errorcode=1 else 'Delete the latest OR in the sql_or sql_or=left(sql_or,len(sql_or)-3) end if '-------- Here start the error handling --------------- %> <% if errorcode=1 then %>

Input error 1. Please enter at least three letters with a wildcard

Return

<% elseif errorcode=2 then %>

Input error 2. Please do not enter successive wildcards

Return

<% elseif errorcode=3 then %>

Input error 3. Please enter at least three letters between wildcards

Return

<% elseif errorcode=4 then %>

Input error 4. Please enter at least three letters

Return

<% else %> <% 'There was no problems in the input -------- 'The SQL statement changes depending a Reference is selected or not. If Request("RefId")<>"" then SQL=SQL&"SELECT DISTINCT Name.NameCache AS Name FROM Name INNER JOIN PTaxon ON Name.NameId = PTaxon.PTNameFk WHERE ("& sql_or &") AND PTRefFk="& Request("RefId") & " ORDER BY Name.NameCache" else SQL=SQL&"SELECT DISTINCT Name.NameCache AS Name FROM Name INNER JOIN PTaxon ON Name.NameId = PTaxon.PTNameFk WHERE "& sql_or &" ORDER BY Name.NameCache" end if 'Response.write(SQL) Set Rspecie = Server.CreateObject("ADODB.Recordset") Rspecie.ActiveConnection = MM_jun_STRING Rspecie.Source = SQL Rspecie.CursorType = 3 Rspecie.CursorLocation = 2 Rspecie.LockType = 1 Rspecie.Open() %> <%' if a reference is selected take his name from the database if Request("RefId")<>"" then SQL="SELECT Refcache FROM reference WHERE RefId="& Request("RefId") Set Rname_ref = Server.CreateObject("ADODB.Recordset") Rname_ref.ActiveConnection = MM_jun_STRING Rname_ref.Source = SQL Rname_ref.CursorType = 3 Rname_ref.CursorLocation = 2 Rname_ref.LockType = 1 Rname_ref.Open() name_ref=Rname_ref("RefCache") Rname_ref.close set Rname_ref=Nothing end if %>

<%=Rspecie.Recordcount%> names found. Click on name for details. <%if Request("RefId")<>"" then%> Search restricted to: <%=name_ref%>

<%end if%>

Matches:

<% if Rspecie.RecordCount>0 then %> <% While NOT Rspecie.EOF %> &PTRefFk=<%=Request("RefId")%>"><%=Replace(Rspecie("Name"),chr(34),""")%>
<% Rspecie.Movenext Wend %>
<%else %>
There are not results matching your query. <%end if%> <% Rspecie.close set Rspecie=Nothing %>
<% 'end of the error in the input handled end if %>