Seamus,

I wrote the VBScript you needed, however I have a couple questions.

Will your Title variable ever have spaces in it?

If so, you will need to change your delimiter from
a space to something more reliable like a pipe or comma.

In the sections where I response.write, you will most likely want to change
them to variables, appending each new SQL statement to the previous.


Here is a working VBScript example:
<pre>
<code>

<%
' author: Joseph DeVore
' date: Saturday, November 17, 2001

dim arTitle, arAuthor, i
' create temp list of titles
title="this_example that_example his_example"

' create temp list of authors
author="devore forta helms"

' split lists into arrays
arTitle = split(Title," ")
arAuthor = split(Author," ")

' loop over title array
for i=0 to ubound(arTitle)
        ' write response to client
        response.write("AND Title LIKE '%" & arTitle(i) & "%'" & vbcrlf)
next

' loop over author array
for i=0 to ubound(arAuthor)
        ' write response to client
        response.write("AND Author LIKE '%" & arAuthor(i) & "%'" & vbcrlf)
next

' if length of form.category_id
if len(request.form("category_id")) then
        ' write response to client
        response.write("AND shstock.CategoryID=" & request.form("category_id") & ""
& vbcrlf)
end if
%>

</code>
</pre>


Let me know what you think or if you have any questions.

Joseph DeVore
VeloxWeb Technologies





-----Original Message-----
From: Seamus Campbell [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 16, 2001 8:40 PM
To: CF-Talk
Subject: traitorous question re VBScript


Hi

can anyone help me with this rather traitorous question

I'm putting a small search page in a friend's website (which is not
cf-enabled, unfortunately)

The search results code I want is (in coldfusion):

<cfquery name="get_titles" datasource="gaslight_cf" dbtype="ODBC">
SELECT tbl_category.category, shstock.BOOKNUM, shstock.TITLE,
shstock.Author, shstock.PRICE, shstock.CategoryID
FROM tbl_category INNER JOIN shstock ON tbl_category.category_id =
shstock.CategoryID
WHERE 0=0

<CFLOOP INDEX="i" FROM="1" TO="#ListLen(Title, ' ')#">   AND Title LIKE
'%#ListGetAt(Title, i, " ")#%' </CFLOOP>
<CFLOOP INDEX="i" FROM="1" TO="#ListLen(Author, ' ')#">   AND Author LIKE
'%#ListGetAt(Author, i, " ")#%' </CFLOOP>
<CFIF Len(FORM.Category_id)>
AND shstock.CategoryID=#FORM.Category_id#
</CFIF>

ORDER BY Title

</CFQUERY>


Is anyone able to translate the middle bit to VBScript for me, please
ie
<CFLOOP INDEX="i" FROM="1" TO="#ListLen(Title, ' ')#">   AND Title LIKE
'%#ListGetAt(Title, i, " ")#%' </CFLOOP>
<CFLOOP INDEX="i" FROM="1" TO="#ListLen(Author, ' ')#">   AND Author LIKE
'%#ListGetAt(Author, i, " ")#%' </CFLOOP>
<CFIF Len(FORM.Category_id)>
AND shstock.CategoryID=#FORM.Category_id#
</CFIF>


MTIA

Seamus


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to