here is what i think...as i am going to implement the same thing...

when you get the parameter from the first page, first check
all parameters which are passed to current page by
request.getParameterNames(). This method will return u an Enumaration...
Now have a String called query... then take one by one element from
enumeration
and simultaneously modify your query as you get parameters from
enumeration...
e.g. let's say i am expecting three parameters p1,p2 and p3 and their
values...
so here is how i will do...
-----------------------------------------------------------
String query = "SELECT <fieldNames> from <tableName> WHERE ";
Enumeration enum = request.getParameterNames();
while(enum.hasMoreElements()){
  String element = (String)enum.nextElement();
  if(element.equals("p1")){
    String valueOfP1 = request.getParameter("p1");
    query = query + "<fieldName>='"+valueOfP1+"' OR";
  }
  if(element.equals("p2")){
    String valueOfP2 = request.getParameter("p2");
    query = query + "<fieldName>='"+valueOfP2+"' OR";
  }
  if(element.equals("p3")){
    String valueOfP3 = request.getParameter("p3");
    query = query + "<fieldName>='"+valueOfP3+"' OR";
  }
  if(query.endsWith("OR")){
    query = query.subtring(0,query.lastIndexOf("OR"));
  }
}
------------------------------------------------------------
i am not sure this is exactly the implementation but just a thought...
i will try that on my own...i may modify some in here...
but kind of direction...hope this may help you and me also :)

Nishit

-----Original Message-----
From: Jun wang [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 01, 2001 10:37 PM
To: [EMAIL PROTECTED]
Subject: Search Code


Hi all,

I did the code for searching video.
My purpose is the user may enter
Type, Title or Actor, or either any
two of them, or all of them.

The code can work individually, but
after put them together, it only works on
last query which to enter all of them
three. Could anyone give any idea?
Thanks in advance!!


Code:

<%
  if( VideoType == "ALL" )
   {
     if( VideoTitle == "" )
      {
        if( VideoActor == "" ) {
           strSQL = "SELECT ISBN, V_Title, V_Type,
                    V_Actor, V_Time FROM
                    Video_Catalog";
           }
        else {
           strSQL = strSELECT + "V_Actor = '" +
                    VideoActor + "'";
           }
      }

      else
      {
        if( VideoActor=="" ) {
           strSQL = strSELECT + "V_Title = '" +
                    VideoTitle + "'";
          }
        else {
           strSQL = strSELECT + "V_Title = '" +
                    VideoTitle + "' AND V_Actor = '" +

                    VideoActor + "'";
         }
      }
   }

  else
  {
   if( VideoTitle=="")
    {
      if( VideoActor==""){
         strSQL = strSELECT + "V_Type = '" + VideoType
                  + "'";
        }
      else{
         strSQL = strSELECT + "V_Type = '" + VideoType
                  + "' AND V_Actor = '" + VideoActor
                  + "'";
          }
      }

   else
    {
      if( VideoActor==""){
        strSQL = strSELECT + "V_Type = '" + VideoType
                 + "' AND V_Title = '" + VideoTitle
                 + "'";
         }
      else {
        strSQL = strSELECT + "V_Type = '" + VideoType
                 + "' AND V_Title = '" + VideoTitle +
                "' AND V_Actor = '" + VideoActor + "'";
         }
     }
   }
%>

<%  rs = statement.executeQuery( strSQL ); %>


Jun Wang



__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to