Click to See Complete Forum and Search --> : Getting the field info from a specific record
telmessos
08-19-2006, 12:37 PM
Hi all,
I have a table where nearly all fields are True/False type. After calling the specific record with ID using SQL, how can I get only the True ones in the record and display on my page. Is there a way for that ? Or do I have to write an if.. then.. else and display it on the page?
Thanks
Ceyhun
sindhusing
08-20-2006, 04:25 AM
in the sql statement u can add an where clause to chk and display all true fields thats the best solution
telmessos
08-20-2006, 03:25 PM
No I think you misunderstood my question. The table which I have is for keeping the information of the holiday rental houses. I call one house using the SQL with ID. After that I need to list only the fields which are true on the display page. Is there an easy way to do this or do I need to check one by one?
Terrorke
08-21-2006, 04:46 AM
You can check the value of the column in ASP before displaying it.
If the valueof the column is true then display it else you get the next column.
Here is some code that should help you on the way :
dim Displaystring , id
id = somerecordID
sql = "select column1, column2, column3 ,... from table where id = '"&id&"'"
set rsQuery = db.execute(sql)
while not rsQuery.eof
if rsQuery("column1") = true then
Displaystring = Displaystring & " column1"
end if
if rsQuery("column2") = true then
Displaystring = Displaystring & " column2"
end if
if rsQuery("column3") = true then
Displaystring = Displaystring & " column3"
end if
...
rsQuery.movenext
wend
You can also use an array to store the columnnames and evaluate them.
telmessos
08-21-2006, 05:35 AM
So basicly, if I have 50 fields to check I have to write 50 if.. end if statements :) Thanks.
Terrorke
08-21-2006, 07:16 AM
Then you maybe could prefer the use of an array containing all the column names and loop thru this array checking the value of that specific column :)