|
dzirkelb1 -> RE: One submit form to search multiple fields? (4/8/2005 12:04:04)
|
Ok, to get a dropdown for your fields (or columns, whichever you wish to call it) you can do it the old fashioned way of <option value="first name">First Name</option> where "first name" is your exact name of the column...or, if there is a lot of them, you can use a quich script as follows: <% DIM myDSN, myConn, mySQL, myTempRS, F connection=request.querystring("Connection") mySQL = "SELECT * FROM Table" myDSN = Application("database_ConnectionString") Response.write("<select size='1' name='FieldName'><option></option>" & VbCrLf) set myConn=server.createobject("adodb.connection") myConn.open myDSN set myTempRS=myConn.execute(mySQL) For Each F In myTempRS.Fields Response.write("<option>" & F.Name & "</option>" & VbCrLf) Next myTempRS.close Set myTempRS = nothing myConn.close Set myConn = nothing Response.write("</select>" & VbCrLf) %> The select statement will change, basically whatever you put in there to display will be the column headings. The bolded database is your connection...whatever you called it in your front page. Your search box will stay the same, for this purpose, lets call the name of it SearchField. Now, the next page you will want to display your search results...the sql statement will look like this: <% FieldName= Replace(Request("FieldName"),"'","''") If FieldName= "" then FieldName= "First Name" -(this is optional) fp_sQry="SELECT * FROM Table WHERE (&FieldName&='::SearchField::')" I am guessing the second sql statement won't work at the &FieldName& because I am unsure of the exact syntax, but give that a whirl :)
|
|
|
|