Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Search Problem
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

blackinwhite
Average Member

Turkey
657 Posts

Posted - 10 November 2001 :  15:36:30  Show Profile
what is wrong with this code.
Normally it must seacrh through the blogs under the topics. But when I run search, it gives me all the same things.
It is:

SELECT fldMessageID, fldPersonID, fldTopicID, fldMessageCreated, fldMessageTitle, fldMessageHeader, fldMessageText FROM tblMessages WHERE fldMessageText <> ''

fldMessageText <> ''

Radiohead ve "copycat"lar (<--they rae all the same message and message id=1

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

Radiohead ve "copycat"lar

and th,is is the code:

<!-- #INCLUDE FILE="inc_asp.asp" -->
<!-- #INCLUDE FILE="func_sql.asp" -->
<%
' Declare SQL Strings
Dim strSQLSearch
Dim strSQLTopics
' /Declare SQL Strings

' Declare Recordset Objects
Dim objRSSearch
Set objRSSearch = Server.CreateObject("ADODB.Recordset")
Dim objRSTopics
Set objRSTopics = Server.CreateObject("ADODB.Recordset")
' /Declare Recordset Objects

' Declare Strings
Dim fSearchText
Dim fSearchAndOr
Dim strSearchText
Dim strSearchAndOr
Dim strSearchWords
Dim qType
Dim qPersonID
Dim qTopicID
Dim strMessageID
Dim strMessageTitle
Dim strCommentID
Dim strCommentTitle
' /Declare Strings


' Declare Integers
Dim iSearchWordsCount
Dim iLooping
Dim iPageSize
Dim iPageCurrent
Dim iRecordsShown
' /Declare Integers

iPageSize = 20
iPageCurrent = 1

' Collect Data
qType = LCase((Trim(Request.QueryString("type"))))

If qType = "" Then
qType = ((Trim(Request.Form("type"))))
End If

If qType = "" Then
qType = "messages"
End If

fSearchText = ((Trim(Request.Form("text"))))
strSearchText = SQLText(fSearchText)

qPersonID = ((Trim(Request.QueryString("person"))))

If qPersonID = "" Then
qPersonID = ((Trim(Request.Form("person"))))
End If

qTopicID = ((Trim(Request.QueryString("topic"))))

If qTopicID = "" Then
qTopicID = ((Trim(Request.Form("topic"))))
End If

fSearchAndOr = ((Trim(Request.Form("andor"))))

If fSearchAndOr = "on" Then
strSearchAndOr = "AND"
Else
strSearchAndOr = "OR"
End If
' /Collect Data

objRSSearch.PageSize = iPageSize
objRSSearch.CacheSize = iPageSize

' Declare The Title
strTitle = "Search"
' /Declare The Title

strSearchWords = Split(strSearchText," ")
iSearchWordsCount = Ubound(strSearchWords)

strSQLTopics = strSQLTopics & "SELECT * "
strSQLTopics = strSQLTopics & "FROM tblTopics "
strSQLTopics = strSQLTopics & "ORDER BY fldTopicName DESC "
Set objRSTopics = objConn.Execute(strSQLTopics)

' Search HTML
strText = strText & "<span class=baslik>Arama</span>"
strText = strText & "<form action=""search.asp"" method=""post"">"
strText = strText & "<p>Kriterler: Messages <input name=""type"" type=""radio"" value=""messages"" checked /> " & strConfigTitleDivider & " Comments <input name=""type"" type=""radio"" value=""comments"" />"
strText = strText & "<p>Search For: <input name=""text"" type=""text"" size=""20"" maxlength=""50"" "
If strSearchText <> "" Then
strText = strText & "value=""" & FormText(strSearchText) & """ "
End If
strText = strText & "/>"
strText = strText & "  " & strConfigTitleDivider & "  Topic: <select name=""topic""><option value="""">All Topics</option>"
Do While Not objRSTopics.EOF
strText = strText & "<option value=""" & objRSTopics.Fields("fldTopicID") & """>" & objRSTopics.Fields("fldTopicName") & "</option>"
objRSTopics.MoveNext
Loop
strText = strText & "</select>"
strText = strText & "  " & strConfigTitleDivider & "  Person ID (<a href=""people.asp"">find a person</a>): <input name=""person"" type=""text"" size=""10"" maxlength=""50"" "
If qPersonID <> "" Then
strText = strText & "value=""" & qPersonID & """ "
End If
strText = strText & "/></p>"
strText = strText & "<p><input name=""submit"" type=""submit"" value=""Submit"" /></p>"
strText = strText & "</form>"
' Search HTML

Select Case qType
Case "messages":
strSQLSearch = strSQLSearch & "SELECT fldMessageID, fldPersonID, fldTopicID, fldMessageCreated, fldMessageTitle, fldMessageHeader, fldMessageText "
strSQLSearch = strSQLSearch & "FROM tblMessages "
strSQLSearch = strSQLSearch & "WHERE "

If strSearchText <> "" Then
For iLooping = 0 to iSearchWordsCount
strSQLSearch = strSQLSearch & "fldMessageTitle LIKE '%" & strSearchWords(iLooping) & "%' OR fldMessageHeader LIKE '%" & strSearchWords(iLooping) & "%' OR fldMessageText LIKE '%" & strSearchWords(iLooping) & "%' "
If iLooping = iSearchWordsCount Then
strSQLSearch= strSQLSearch & ""
Else
strSQLSearch = strSQLSearch & strSearchAndOr & " "
End If
Next
Else
strSQLSearch = strSQLSearch & "fldMessageText <> '' "
End If
If qTopicID <> "" Then
strSQLSearch = strSQLSearch & "AND "
strSQLSearch = strSQLSearch & "fldTopicID = " & qTopicID & " "
End If
If qPersonID <> "" Then
strSQLSearch = strSQLSearch & "AND "
strSQLSearch = strSQLSearch & "fldPersonID = " & qPersonID & ""
End If
strText = strText & strSQLSearch
objRSSearch.Open strSQLSearch, objConn, adOpenStatic

iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not objRSSearch.EOF

objRSSearch.AbsolutePage = iPageCurrent

strMessageID = objRSSearch.Fields("fldMessageID")
strMessageTitle = objRSSearch.Fields("fldMessageTitle")

' Search HTML
strText = strText & "<p><a href=""messages.asp?message=" & objRSSearch.Fields("fldMessageID") & """>" & objRSSearch.Fields("fldMessageTitle") & "</p>"
' Search HTML
iRecordsShown = iRecordsShown + 1
objRSSearch.MoveNext
Loop

Case "comments":
strSQLSearch = strSQLSearch & "SELECT fldCommentID, fldPersonID, fldMessageID, fldCommentParentID, fldCommentCreated, fldCommentTitle, fldCommentText "
strSQLSearch = strSQLSearch & "FROM tblComments "
strSQLSearch = strSQLSearch & "WHERE "

If strSearchText <> "" Then
For iLooping = 0 to iSearchWordsCount
strSQLSearch= strSQLSearch & "fldCommentTitle, fldCommentText LIKE '%" & strSearchWords(iLooping) & "%' "
If iLooping = iSearchWordsCount Then
strSQLSearch= strSQLSearch & ""
Else
strSQLSearch= strSQLSearch & strSearchAndOr & " "
End If
Next
Else
strSQLSearch = strSQLSearch & "fldCommentText <> '' "
End If

If qPersonID <> "" Then
strSQLSearch = strSQLSearch & "AND "
strSQLSearch = strSQLSearch & "fldPersonID = " & qPersonID & ""
End If

objRSSearch.Open strSQLSearch, objConn, adOpenStatic



iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not objRSSearch.EOF

objRSSearch.AbsolutePage = iPageCurrent

strCommentID = objRSSearch.Fields("fldCommentID")
strMessageID = objRSSearch.Fields("fldMessageID")
strCommentTitle = objRSSearch.Fields("fldCommentTitle")

' Search HTML
strText = strText & "<p><a href=""messages.asp?message=" & strMessageID & "#" & strCommentID & """>" & strCommentTitle & "</p>"
' Search HTML
iRecordsShown = iRecordsShown + 1
objRSSearch.MoveNext
Loop

End Select

%>
<!-- #INCLUDE FILE="inc_html.asp" -->

____
"I am a legal alien"

Edited by - blackinwhite on 10 November 2001 15:41:13

blackinwhite
Average Member

Turkey
657 Posts

Posted - 11 November 2001 :  04:25:03  Show Profile
here is what it must be: (shane solved it)

<%
' Declare SQL Strings
Dim strSQLSearch
Dim strSQLTopics
' /Declare SQL Strings

' Declare Recordset Objects
Dim objRSSearch
Set objRSSearch = Server.CreateObject("ADODB.Recordset")
Dim objRSTopics
Set objRSTopics = Server.CreateObject("ADODB.Recordset")
' /Declare Recordset Objects

' Declare Strings
Dim fSearchText
Dim fSearchAndOr
Dim strSearchText
Dim strSearchAndOr
Dim strSearchWords
Dim qType
Dim qPersonID
Dim qTopicID
Dim strMessageID
Dim strMessageTitle
Dim strCommentID
Dim strCommentTitle
' /Declare Strings


' Declare Integers
Dim iSearchWordsCount
Dim iLooping
Dim iPageSize
Dim iPageCurrent
Dim iRecordsShown

Dim lngRecCnt
Dim lngPageCnt

' /Declare Integers

iPageSize = 20
iPageCurrent = 1

' Collect Data
qType = LCase((Trim(Request.QueryString("type"))))

If qType = "" Then
qType = ((Trim(Request.Form("type"))))
End If

If qType = "" Then
qType = "messages"
End If

fSearchText = ((Trim(Request.Form("text"))))
strSearchText = SQLText(fSearchText)

qPersonID = ((Trim(Request.QueryString("person"))))

If qPersonID = "" Then
qPersonID = ((Trim(Request.Form("person"))))
End If

qTopicID = ((Trim(Request.QueryString("topic"))))

If qTopicID = "" Then
qTopicID = ((Trim(Request.Form("topic"))))
End If

fSearchAndOr = ((Trim(Request.Form("andor"))))

If fSearchAndOr = "on" Then
strSearchAndOr = "AND"
Else
strSearchAndOr = "OR"
End If
' /Collect Data

objRSSearch.PageSize = iPageSize
objRSSearch.CacheSize = iPageSize

' Declare The Title
strTitle = "Search"
' /Declare The Title

strSearchWords = Split(strSearchText," ")
iSearchWordsCount = Ubound(strSearchWords)

strSQLTopics = strSQLTopics & "SELECT * "
strSQLTopics = strSQLTopics & "FROM tblTopics "
strSQLTopics = strSQLTopics & "ORDER BY fldTopicName DESC "
Set objRSTopics = objConn.Execute(strSQLTopics)

' Search HTML
strText = strText & "<span class=baslik>Arama</span>"
strText = strText & "<form action=""search.asp"" method=""post"">"
strText = strText & "<p>Kriterler: Messages <input name=""type"" type=""radio"" value=""messages"" checked /> " & strConfigTitleDivider & " Comments <input name=""type"" type=""radio"" value=""comments"" />"
strText = strText & "<p>Search For: <input name=""text"" type=""text"" size=""20"" maxlength=""50"" "
If strSearchText <> "" Then
strText = strText & "value=""" & FormText(strSearchText) & """ "
End If
strText = strText & "/>"
strText = strText & "  " & strConfigTitleDivider & "  Topic: <select name=""topic""><option value="""">All Topics</option>"
Do While Not objRSTopics.EOF
strText = strText & "<option value=""" & objRSTopics.Fields("fldTopicID") & """>" & objRSTopics.Fields("fldTopicName") & "</option>"
objRSTopics.MoveNext
Loop
strText = strText & "</select>"
strText = strText & "  " & strConfigTitleDivider & "  Person ID (<a href=""people.asp"">find a person</a>): <input name=""person"" type=""text"" size=""10"" maxlength=""50"" "
If qPersonID <> "" Then
strText = strText & "value=""" & qPersonID & """ "
End If
strText = strText & "/></p>"
strText = strText & "<p><input name=""submit"" type=""submit"" value=""Submit"" /></p>"
strText = strText & "</form>"
' Search HTML

Select Case qType
Case "messages":
strSQLSearch = strSQLSearch & "SELECT fldMessageID, fldPersonID, fldTopicID, fldMessageCreated, fldMessageTitle, fldMessageHeader, fldMessageText "
strSQLSearch = strSQLSearch & "FROM tblMessages "
strSQLSearch = strSQLSearch & "WHERE "

If strSearchText <> "" Then
For iLooping = 0 to iSearchWordsCount
strSQLSearch = strSQLSearch & "fldMessageTitle LIKE '%" & strSearchWords(iLooping) & "%' OR fldMessageHeader LIKE '%" & strSearchWords(iLooping) & "%' OR fldMessageText LIKE '%" & strSearchWords(iLooping) & "%' "
If iLooping = iSearchWordsCount Then
strSQLSearch= strSQLSearch & ""
Else
strSQLSearch = strSQLSearch & strSearchAndOr & " "
End If
Next
Else
strSQLSearch = strSQLSearch & "fldMessageText <> '' "
End If
If qTopicID <> "" Then
strSQLSearch = strSQLSearch & "AND "
strSQLSearch = strSQLSearch & "fldTopicID = " & qTopicID & " "
End If
If qPersonID <> "" Then
strSQLSearch = strSQLSearch & "AND "
strSQLSearch = strSQLSearch & "fldPersonID = " & qPersonID & ""
End If
' strText = strText & strSQLSearch
objRSSearch.Open strSQLSearch, objConn, adOpenStatic

'sonradan ekledim
If Not objRSSearch.EOF Then
iRecordsShown = 0

'Get the record count
lngRecCnt = objRSSearch.RecordCount

'Set the rs page size (the default is 10)
objRSSearch.PageSize = iPageSize

'Get the page count
lngPageCnt = objRSSearch.PageCount

'Check that current page value is within range
If CLng(iPageCurrent) < 1 Then
iPageCurrent = 1
End If
If CLng(iPageCurrent) > CLng(lngPageCnt) Then
iPageCurrent = lngPageCnt
End If

'Set the rs page (moving the cursor to first rec of the page)
objRSSearch.AbsolutePage = iPageCurrent

Do While iRecordsShown < iPageSize And Not objRSSearch.EOF


strMessageID = objRSSearch.Fields("fldMessageID")
strMessageTitle = objRSSearch.Fields("fldMessageTitle")

' Search HTML
strText = strText & "<p><a href=""messages.asp?message=" & _
objRSSearch.Fields("fldMessageID") & """>" & _
objRSSearch.Fields("fldMessageTitle") & "</p>"
' Search HTML



iRecordsShown = iRecordsShown + 1
objRSSearch.MoveNext
Loop
Else
'No records found, so let the user know
Response.Write "<p>Sorry, no matches found.</p>"
End If

'/sonradan


' iRecordsShown = 0
' Do While iRecordsShown < iPageSize And Not objRSSearch.EOF

' strMessageID = objRSSearch.Fields("fldMessageID")
' strMessageTitle = objRSSearch.Fields("fldMessageTitle")

' Search HTML
' strText = strText & "<p><a href=""messages.asp?message=" & objRSSearch.Fields("fldMessageID") & """>" & objRSSearch.Fields("fldMessageTitle") & "</p>"
' Search HTML
' iRecordsShown = iRecordsShown + 1
' objRSSearch.MoveNext
' Loop

Case "comments":
strSQLSearch = strSQLSearch & "SELECT fldCommentID, fldPersonID, fldMessageID, fldCommentParentID, fldCommentCreated, fldCommentTitle, fldCommentText "
strSQLSearch = strSQLSearch & "FROM tblComments "
strSQLSearch = strSQLSearch & "WHERE "

If strSearchText <> "" Then
For iLooping = 0 to iSearchWordsCount
strSQLSearch= strSQLSearch & "fldCommentTitle LIKE '%" & strSearchWords(iLooping) & "%' OR " & _
"fldCommentText LIKE '%" & strSearchWords(iLooping) & "%' "
If iLooping = iSearchWordsCount Then
strSQLSearch= strSQLSearch & ""
Else
strSQLSearch= strSQLSearch & strSearchAndOr & " "
End If
Next
Else
strSQLSearch = strSQLSearch & "fldCommentText <> '' "
End If

If qPersonID <> "" Then
strSQLSearch = strSQLSearch & "AND "
strSQLSearch = strSQLSearch & "fldPersonID = " & qPersonID & ""
End If

'Response.Write "SQL (comment search): " & strSQLSearch
'Response.End

objRSSearch.Open strSQLSearch, objConn, adOpenStatic



If Not objRSSearch.EOF Then
iRecordsShown = 0

'Get the record count
lngRecCnt = objRSSearch.RecordCount

'Set the rs page size (the default is 10)
objRSSearch.PageSize = iPageSize

'Get the page count
lngPageCnt = objRSSearch.PageCount

'Check that current page value is within range
If CLng(iPageCurrent) < 1 Then
iPageCurrent = 1
End If
If CLng(iPageCurrent) > CLng(lngPageCnt) Then
iPageCurrent = lngPageCnt
End If

'Set the rs page (moving the cursor to first rec of the page)
objRSSearch.AbsolutePage = iPageCurrent

Do While iRecordsShown < iPageSize And Not objRSSearch.EOF

strCommentID = objRSSearch.Fields("fldCommentID")
strMessageID = objRSSearch.Fields("fldMessageID")
strCommentTitle = objRSSearch.Fields("fldCommentTitle")

' Search HTML
strText = strText & "<p><a href=""messages.asp?message=" & strMessageID & _
"#" & strCommentID & """>" & strCommentTitle & "</p>"
' Search HTML

iRecordsShown = iRecordsShown + 1

objRSSearch.MoveNext
Loop
Else
'No records found, so let the user know
Response.Write "<p>Sorry, no matches found.</p>"
End If

End Select

%>



____
"I am a legal alien"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.83 seconds. Powered By: Snitz Forums 2000 Version 3.4.07