Click to See Complete Forum and Search --> : search checked in for-next loop


gilgalbiblewhee
07-27-2005, 11:20 PM
This might sound complicated for me to explain but I'll try.

I have two columns in the database table where one is the "id" and the other "text_data".

I filled on a page checkboxes for the id and textareas for "text_data" per id.

<input type="submit" value=" Search " size="100" title="Search everything selected">

for....
<input type="checkbox" value="<%=RS("id")%>" name="id"><br/>
<%
Response.Write "<textarea "
response.write "name=""Keywordh"""
response.write "value=""Keywordh"""
response.write "rows=""3"" "
response.write "cols=""64"">"
response.write "</textarea>"
next....


there must be something wrong right of the start because when press "search" without checking anything it searches every textarea within the for-next loop. My intention is to search ONLY the textareas that are checked.

BUt I'm also wondering if it is necessary to have a textarea to make these searches. Is it possible to simply slap the "text_data" alone in the for-next, check the ones I choose and search?

minority
07-28-2005, 05:08 AM
eh k if its returning and searching everything then its going to be in your sql not your form.

really need to see your sql

gilgalbiblewhee
07-28-2005, 02:56 PM
I used a recycled script, so I don't know if this is correct.


Dim id
Dim Keywordh

SQL= "SELECT * "
SQL = SQL & " FROM bible WHERE "
id = Request.QueryString("id")
Keywordh = Trim(Request.QueryString("Keywordh"))
'If rs("id")="yes" then
'If Trim(Request.QueryString("id")) <> "" Then
' aRecTypes = Split(id, ",")
' If IsArray(aRecTypes) Then
SQL = SQL & " ("
' For iLoopCount = 0 To UBound(aRecTypes)
If iLoopCount <> 0 Then
SQL = SQL & " OR "
End If
SQL = SQL & "id = " & id
' Next
' End If
SQL = SQL & ")"

' If iCounter <> 0 Then
SQL = SQL & " AND "
' End If
SQL = SQL & " ( "
myarray = split(Keywordh," ")
whereclause="text_data like '%" & myarray(0) & "%'"
for counter=1 to ubound(myarray)
whereclause = whereclause & " OR text_data like '%" & myarray(counter) & "%'"
next
SQL = SQL & whereclause
SQL = SQL & " ) "
iCounter = iCounter + 1


'End If
'End If