Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ok i have this code: <%

Status
Not open for further replies.

deddleston

Programmer
Oct 4, 2002
43
GB
Ok i have this code:

<%

DAOImplementer dao = new DAOImplementer();
String query = &quot;SELECT &quot;;
System.out.println( &quot;component_name: &quot;+ request.getParameter(&quot;component_name&quot;) );
System.out.println( &quot;chbxTN: &quot;+ request.getParameter(&quot;chbxTN&quot;) );
System.out.println( &quot;chbxTD: &quot;+ request.getParameter(&quot;chbxTD&quot;) );
System.out.println( &quot;chbxTDV: &quot;+ request.getParameter(&quot;chbxTDV&quot;) );

//add the fields you are selecting to the query
//Table section
if ((request.getParameter(&quot;chbxTN&quot;) != null) && (request.getParameter(&quot;chbxTD&quot;) == null)
&& (request.getParameter(&quot;chbxTDV&quot;) == null)){
query = query + (request.getParameter(&quot;chbxTN&quot;));
}
if ((request.getParameter(&quot;chbxTN&quot;) == null) && (request.getParameter(&quot;chbxTD&quot;) != null)
&& (request.getParameter(&quot;chbxTDV&quot;) == null)){
query = query +(request.getParameter(&quot;chbxTD&quot;));
}
if ((request.getParameter(&quot;chbxTN&quot;) == null) && (request.getParameter(&quot;chbxTD&quot;) == null)
&& (request.getParameter(&quot;chbxTDV&quot;) != null)){
query = query +(request.getParameter(&quot;chbxTDV&quot;));
}
if ((request.getParameter(&quot;chbxTN&quot;) != null) && (request.getParameter(&quot;chbxTD&quot;) != null)
&& (request.getParameter(&quot;chbxTDV&quot;) == null)){
query = query +(request.getParameter(&quot;chbxTN&quot;)) +&quot;, &quot; +(request.getParameter(&quot;chbxTD&quot;));
}
if ((request.getParameter(&quot;chbxTN&quot;) == null) && (request.getParameter(&quot;chbxTD&quot;) != null)
&& (request.getParameter(&quot;chbxTDV&quot;) != null)){
query = query +(request.getParameter(&quot;chbxTD&quot;)) +&quot;, &quot; +(request.getParameter(&quot;chbxTDV&quot;));
}
if ((request.getParameter(&quot;chbxTN&quot;) != null) && (request.getParameter(&quot;chbxTD&quot;) == null)
&& (request.getParameter(&quot;chbxTDV&quot;) != null)){
query = query +(request.getParameter(&quot;chbxTN&quot;)) +&quot;, &quot; +(request.getParameter(&quot;chbxTDV&quot;));
}
if ((request.getParameter(&quot;chbxTN&quot;) != null) && (request.getParameter(&quot;chbxTD&quot;) != null)
&& (request.getParameter(&quot;chbxTDV&quot;) != null)){
query = query +(request.getParameter(&quot;chbxTN&quot;)) +&quot;, &quot; +(request.getParameter(&quot;chbxTD&quot;))
+&quot;, &quot; +(request.getParameter(&quot;chbxTDV&quot;));
}

System.out.println( &quot;chbxCN: &quot;+ request.getParameter(&quot;chbxCN&quot;) );
System.out.println( &quot;chbxCD: &quot;+ request.getParameter(&quot;chbxCD&quot;) );
System.out.println( &quot;chbxCDV: &quot;+ request.getParameter(&quot;chbxCDV&quot;) );


//Column section

if ((request.getParameter(&quot;chbxCN&quot;) != null) && (request.getParameter(&quot;chbxCD&quot;) == null)
&& (request.getParameter(&quot;chbxCDV&quot;) == null)){
query = query + (request.getParameter(&quot;chbxCN&quot;));
}
if ((request.getParameter(&quot;chbxCN&quot;) == null) && (request.getParameter(&quot;chbxCD&quot;) != null)
&& (request.getParameter(&quot;chbxCDV&quot;) == null)){
query = query +(request.getParameter(&quot;chbxCD&quot;));
}
if ((request.getParameter(&quot;chbxCN&quot;) == null) && (request.getParameter(&quot;chbxCD&quot;) == null)
&& (request.getParameter(&quot;chbxCDV&quot;) != null)){
query = query +(request.getParameter(&quot;chbxCDV&quot;));
}
if ((request.getParameter(&quot;chbxCN&quot;) != null) && (request.getParameter(&quot;chbxCD&quot;) != null)
&& (request.getParameter(&quot;chbxCDV&quot;) == null)){
query = query +(request.getParameter(&quot;chbxCN&quot;)) +&quot;, &quot; +(request.getParameter(&quot;chbxCD&quot;));
}
if ((request.getParameter(&quot;chbxCN&quot;) == null) && (request.getParameter(&quot;chbxCD&quot;) != null)
&& (request.getParameter(&quot;chbxCDV&quot;) != null)){
query = query +(request.getParameter(&quot;chbxCD&quot;)) +&quot;, &quot; +(request.getParameter(&quot;chbxCDV&quot;));
}
if ((request.getParameter(&quot;chbxCN&quot;) != null) && (request.getParameter(&quot;chbxCD&quot;) == null)
&& (request.getParameter(&quot;chbxCDV&quot;) != null)){
query = query +(request.getParameter(&quot;chbxCN&quot;)) +&quot;, &quot; +(request.getParameter(&quot;chbxCDV&quot;));
}
if ((request.getParameter(&quot;chbxCN&quot;) != null) && (request.getParameter(&quot;chbxCD&quot;) != null)
&& (request.getParameter(&quot;chbxCDV&quot;) != null)){
query = query +(request.getParameter(&quot;chbxCN&quot;)) +&quot;, &quot; +(request.getParameter(&quot;chbxCD&quot;))
+&quot;, &quot; +(request.getParameter(&quot;chbxCDV&quot;));
}

%>


You should see there are 2 sections; table and column, i want to evaluate the 2 but depending on the condition do seperate things, so if:
if ((request.getParameter(&quot;chbxTN&quot;) != null) | (request.getParameter(&quot;chbxTD&quot;) != null) | (request.getParameter(&quot;chbxTDV&quot;) != null)

i want to do this
//add FROM (for table selection)
if ((request.getParameter(&quot;component_name&quot;) == null) && (request.getParameter(&quot;instanceName&quot;) == null)){
query = query + &quot; FROM component_table&quot;;
}

if ((request.getParameter(&quot;component_name&quot;) != null) && (request.getParameter(&quot;instanceName&quot;) == null)){
query = query + &quot; FROM component_table, solution_component&quot;;
}
if ((request.getParameter(&quot;component_name&quot;) != null) && (request.getParameter(&quot;instanceName&quot;) != null)){
query = query + &quot; FROM component_table&quot;;
}

if it;s:

if ((request.getParameter(&quot;chbxCN&quot;) != null) | (request.getParameter(&quot;chbxCD&quot;) != null) | (request.getParameter(&quot;chbxCDV&quot;) != null)

i want to do:

//add FROM (for table selection)
if ((request.getParameter(&quot;component_name&quot;) == null) && (request.getParameter(&quot;instanceName&quot;) == null)){
query = query + &quot; FROM data_element&quot;;
}

if ((request.getParameter(&quot;component_name&quot;) != null) && (request.getParameter(&quot;instanceName&quot;) == null)){
query = query + &quot; FROM data_element, solution_component&quot;;
}
if ((request.getParameter(&quot;component_name&quot;) != null) && (request.getParameter(&quot;instanceName&quot;) != null)){
query = query + &quot; FROM data_element&quot;;
}


i'm stuck, any help is greatly apprecitated M$ arn't the only option!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top