View Single Post
  #5 (permalink)  
Old January 11th, 2008, 10:08 AM
kumiko kumiko is offline
Authorized User
 
Join Date: Aug 2006
Location: , , .
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
<%

if request.form("btnSubmit")<>"" then
Dim  selCrit,arrSearch

    if request.form("strsearch") <>"" then
          Call Keywrd(strSQL)
    end if

    set rs = Server.CreateObject("ADODB.RecordSet")    

    Sub Keywrd(strSQL)
             selCrit = "Or"
             chk_photographer= request.Form("photographer")
             strInput= request.form("strsearch")
             strInput=Replace(strInput,","," ")
             //remove extraneous spaces in a string
             Do While InStr(1, strInput, "  ")
                strInput = Replace(strInput, "  ", " ")
             Loop
             response.Write strInput &"<BR>"

             // use split to break it down into an array
             arrSearch = split(strInput," ")
             strName = join(arrSearch, "%') " & selCrit & " (photoname LIKE '%") 
                     strCombine =  join(arrSearch, "%') " & selCrit & " (photokeywords LIKE '%") 
                     strphotographer= join(arrSearch, "%') " & selCrit & " (photographer LIKE '%") 
                     strlightbox= join(arrSearch, "%') " & selCrit & " (keywords LIKE '%") 

               strSQL = "SELECT * FROM tblp_photo"


                    strSQL = strSQL & "  WHERE(photokeywords LIKE '%" & strCombine & "%')"
                    strSQL = strSQL & " OR(photoname LIKE  '%" & strName  & "%')"
                    if request.Form("photographer")= "chkPhoto" then
                       strSQL = strSQL & " OR(photographer LIKE  '%" &  strphotographer & "%')"
                   end if
    End Sub

        rs.Open strSQL,objConn
        If not Rs.EOF Then
            Do While Not Rs.EOF
                response.Write rs("photoname")  &"<BR>"
                response.Write rs("photoid")
            rs.MoveNext
            loop
        end if
                response.write strSQL &"<BR><BR>"
end if

%>
<form name="frm" action="test4.asp" method="post">
<input type="text" name="strsearch" <%if request.form("strsearch")<>"" then  response.write request.form("strsearch") end if %> />
<br />
<input type="checkbox" value="chkPhoto" name="photographer" />
Photographers Name <br />
<input type="checkbox" value="chkLightBox" name="lightbox" />
Lightbox <br />
<input type="submit" name="btnsubmit" value="Submit" />
</form>
</body>
</html>
hi gbianchi,wat i have did is liek the code above. this code help me to query the result by default the photoname and when the yser check the chckbox to search by the photographers name also. but if user check the second checkbox, i duno how to cont to do it. and...if let say user check two checkbox, then how? i really need a help..plz.