| Author |
Need help with search
|
|
|
| Can anyone help with this or am I SOL
I currently have the following code creating a search string and it works
fine until you get to the lower portion if you enter a keyword(search1) it
works fine but if you select a year(years1) it does not return the correct
results and if you dont have a keyword and just want to search by year it
gives me an error because of the AND statement. If anyone can help im kinda
new at this it would be greatly appreciated.
<% Dim SearchString
' Looks for a Category or User
If Request.QueryString("CategoryID") <> "" THEN SearchString = SearchString
& " CategoryID = " & Request.QueryString("CategoryID") END IF
If Request.QueryString("UserID") <> "" THEN SearchString = SearchString & "
UserID = " & Request.QueryString("UserID") END IF
' Search by days
If Request.QueryString("Days") = "3" THEN SearchString = SearchString & "
AdDate >= Date() - 3" END IF
If Request.QueryString("Days") = "7" THEN SearchString = SearchString & "
AdDate >= Date() - 7" END IF
If Request.QueryString("Days") = "14" THEN SearchString = SearchString & "
AdDate >= Date() - 14" END IF
' Looks for search critera from search page
If Request.QueryString("Search1") <> "" THEN SearchString = SearchString & "
Description LIKE '%" & Request.QueryString("Search1") & "%' OR Detailinfo
LIKE '%" & Request.Form("Search1") & "%'" END IF
If Request.QueryString("Years1") <> "0" THEN SearchString = SearchString & "
AND YearID = " & Request.QueryString("Years1") END IF
If Request.QueryString("Brands1") <> "0" THEN SearchString = SearchString &
" AND BrandID = " & Request.QueryString("Brands1") END IF
If Request.QueryString("Scales1") <> "0" THEN SearchString = SearchString &
" AND ScaleID = " & Request.QueryString("Scales1") END IF
SearchString = SearchString
%>
<%
Dim rsResults
Dim rsResults_numRows
Set rsResults = Server.CreateObject("ADODB.Recordset")
rsResults.ActiveConnection = MM_DCT_STRING
rsResults.Source = "SELECT * FROM ResultsQuery WHERE " & SearchString & "
ORDER BY AdDate DESC"
rsResults.CursorType = 0
rsResults.CursorLocation = 2
rsResults.LockType = 1
rsResults.Open()
rsResults_numRows = 0
%>
Steve
| |
| Nancy Gill 2004-08-13, 11:15 pm |
| If you're going to search by either keyword or year, then you need to change
AND to OR.
--
Nancy Gill
Team Macromedia Volunteer for Dreamweaver MX/UltraDev
http://www.macromedia.com/go/team/
BLOG: http://www.dmxwishes.com/blog.html
Co-Author: Dreamweaver MX: Instant Troubleshooter (August, 2003)
Technical Editor: DMX 2004: The Complete Reference, DMX 2004: A Beginner's
Guide, Mastering Macromedia Contribute
Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP Web Development
"Steve" <cymonsez@msn.com> wrote in message
news:cfje2k$2gl$1@forums.macromedia.com...
> Can anyone help with this or am I SOL
>
> I currently have the following code creating a search string and it works
> fine until you get to the lower portion if you enter a keyword(search1) it
> works fine but if you select a year(years1) it does not return the correct
> results and if you dont have a keyword and just want to search by year it
> gives me an error because of the AND statement. If anyone can help im
kinda
> new at this it would be greatly appreciated.
>
>
> <% Dim SearchString
> ' Looks for a Category or User
> If Request.QueryString("CategoryID") <> "" THEN SearchString =
SearchString
> & " CategoryID = " & Request.QueryString("CategoryID") END IF
> If Request.QueryString("UserID") <> "" THEN SearchString = SearchString &
"
> UserID = " & Request.QueryString("UserID") END IF
> ' Search by days
> If Request.QueryString("Days") = "3" THEN SearchString = SearchString & "
> AdDate >= Date() - 3" END IF
> If Request.QueryString("Days") = "7" THEN SearchString = SearchString & "
> AdDate >= Date() - 7" END IF
> If Request.QueryString("Days") = "14" THEN SearchString = SearchString & "
> AdDate >= Date() - 14" END IF
> ' Looks for search critera from search page
> If Request.QueryString("Search1") <> "" THEN SearchString = SearchString &
"
> Description LIKE '%" & Request.QueryString("Search1") & "%' OR Detailinfo
> LIKE '%" & Request.Form("Search1") & "%'" END IF
> If Request.QueryString("Years1") <> "0" THEN SearchString = SearchString &
"
> AND YearID = " & Request.QueryString("Years1") END IF
> If Request.QueryString("Brands1") <> "0" THEN SearchString = SearchString
&
> " AND BrandID = " & Request.QueryString("Brands1") END IF
> If Request.QueryString("Scales1") <> "0" THEN SearchString = SearchString
&
> " AND ScaleID = " & Request.QueryString("Scales1") END IF
> SearchString = SearchString
> %>
> <%
> Dim rsResults
> Dim rsResults_numRows
>
> Set rsResults = Server.CreateObject("ADODB.Recordset")
> rsResults.ActiveConnection = MM_DCT_STRING
> rsResults.Source = "SELECT * FROM ResultsQuery WHERE " & SearchString &
"
> ORDER BY AdDate DESC"
> rsResults.CursorType = 0
> rsResults.CursorLocation = 2
> rsResults.LockType = 1
> rsResults.Open()
>
> rsResults_numRows = 0
> %>
>
>
>
> Steve
>
>
>
| |
| Steve 2004-08-13, 11:15 pm |
| Im looking for the keyword(search1) and if they select a year(years1) i want
it to be included so the results would only be the years that contain the
keyword
Steve
"Nancy Gill" <nancy@webwish.com> wrote in message
news:cfjgat$46m$1@forums.macromedia.com...
> If you're going to search by either keyword or year, then you need to
change
> AND to OR.
>
>
> --
> Nancy Gill
> Team Macromedia Volunteer for Dreamweaver MX/UltraDev
> http://www.macromedia.com/go/team/
> BLOG: http://www.dmxwishes.com/blog.html
> Co-Author: Dreamweaver MX: Instant Troubleshooter (August, 2003)
> Technical Editor: DMX 2004: The Complete Reference, DMX 2004: A
Beginner's
> Guide, Mastering Macromedia Contribute
> Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP Web
Development
>
> "Steve" <cymonsez@msn.com> wrote in message
> news:cfje2k$2gl$1@forums.macromedia.com...
works[color=darkred]
it[color=darkred]
correct[color=darkred]
it[color=darkred]
> kinda
> SearchString
&[color=darkred]
> "
"[color=darkred]
"[color=darkred]
"[color=darkred]
&[color=darkred]
> "
Detailinfo[color=darkred]
&[color=darkred]
> "
SearchString[color=darkred]
> &
SearchString[color=darkred]
> &
&[color=darkred]
> "
>
>
| |
| Nancy Gill 2004-08-13, 11:15 pm |
| You need a aubquery, I think.
Try something like this:
SELECT whatever
FROM table
WHERE EXISTS
(SELECT *
FROM table
WHERE keyword LIKE '%keyword%');
Nancy
"Steve" <cymonsez@msn.com> wrote in message
news:cfjit4$5ts$1@forums.macromedia.com...
> Im looking for the keyword(search1) and if they select a year(years1) i
want
> it to be included so the results would only be the years that contain the
> keyword
>
> Steve
>
>
> "Nancy Gill" <nancy@webwish.com> wrote in message
> news:cfjgat$46m$1@forums.macromedia.com...
> change
> Beginner's
> Development
> works
keyword(search1)[color=darkred]
> it
> correct
> it
SearchString[color=darkred]
> &
&[color=darkred]
> "
&[color=darkred]
> "
&[color=darkred]
> "
SearchString[color=darkred]
> &
> Detailinfo
SearchString[color=darkred]
> &
> SearchString
> SearchString
SearchString[color=darkred]
> &
>
>
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |