Hi,
I have a data input form that enables user's to conduct searches on my database.
I am trying to make it so they can have any selection of the fields to run their query.
I thought the best way would be to put the entries from the form into an array, take out all the not null values and put them into an sql query.
Currently I have tried using a single array with just the values, but found I couldn't specify columns in my where clause without knowing what values are not null. To rectify this I tried using a multidimensional array to hold both the field name as it appears in the database, and the value from the form.
I am inexperienced with asp, and I am having problems with extracting the not null values from the array, and I have only vague ideas of how to put them into an sql query.
This is my code:
Code:
<%
var varMemberid = Request.form("memberid");
var varCountry = Request.form("country");
var varCity = Request.form("city");
var varProptype = Request.form("proptype");
var varBeds = Request.form("beds");
var varAccom = Request.form("accom");
var varSmoke = Request.form("smoke");
var varChild = Request.form("child");
var varPets = Request.form("pets");
var varAvail = Request.form("availability");
var varDit = Request.form("dit");
var varpercent = Request.form("percent");
var vardoubledit = Request.form("2dit");
var varsqlstring = "SELECT * FROM tbl_Member M, tbl_Home H WHERE M.MemberID = H.tbl_MemberID ";
var MyArray = new Array(1,9) //declaring a multidimensional array with 2 cols (0, 1) and 10 rows (0-9)
MyArray (0,0) = "MemberID" //enter first variable into the array
MyArray (1,0) = "Country"
MyArray (2,0) = "City"
MyArray (3,0) = "PropertyType"
MyArray (4,0) = "NoBedrooms"
MyArray (5,0) = "NoCanAccommodate"
MyArray (6,0) = "SmokingNon"
MyArray (7,0) = "ChildrenPermitted"
MyArray (8,0) = "PetsPermitted"
MyArray (9,0) = "Availability" //here and above the variables are identical to the field names in tbl_Home
MyArray (0,1) = varMemberid
MyArray (1,1) = varCountry
MyArray (2,1) = varCity
MyArray (3,1) = varProptype
MyArray (4,1) = varBeds
MyArray (5,1) = varAccom
MyArray (6,1) = varSmoke
MyArray (7,1) = varChild
MyArray (8,1) = varPets
MyArray (9,1) = varAvail //these are the variables from above
//UBound(MyArray) to find the highest element in the array
for (a=0; UBound(MyArray,1);a++){
}
All of my code in in HTML and JavaScript, and I can't use any other language.
Any help (or ideas of a simpler way) would be much appreciated!