Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request.Form (simple question)

Status
Not open for further replies.

jreinard

Technical User
Feb 21, 2001
24
0
0
US
I am trying to write a simple search function that will return items from a SQL DB. i am using a basic search form with one text field.

<form name=&quot;search&quot; method=&quot;post&quot; action=&quot;search.asp&quot;>

Item Search<br>

<input type=&quot;text&quot; name=&quot;searchvalue&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value = &quot;Submit&quot;>

</form>


I am trying to get the searchvalue to query against the SQL DB via the request.form function. I am not recieving any errors, but I am not returning any output? Am I calling the function properly?

<%
Dim rsItems
Set rsItems = Server.CreateObject(&quot;ADODB.RecordSet&quot;)

Dim sSql
sSql = &quot;SELECT NO, DESCRIPTION, WEBNAME, UNITPRICE FROM SHOP_ITEM WHERE WEBSITECODE = '&quot; & MSCSSite.NFSiteName & &quot;' AND DESCRIPTION LIKE '&quot; & Request.Form(&quot;searchvalue&quot;) & &quot;' AND PARENTITEM = '' ORDER BY NO&quot;

rsItems.Open sSql, connDB, adOpenForwardOnly, adLockReadOnly


<!-- OUTPUT Method-->


If Not rsItems.EOF Then
%>
<table width=100%>
<%
Do While Not rsItems.EOF
j = j + 1
If j = 1 Then Response.Write &quot;<tr>&quot;
ItemNo = rsItems(MSCSSite.Item_No)
ItemDescription = rsItems(MSCSSite.Item_Description)
WebName = rsItems(MSCSSite.Item_WebName)
UnitPrice = UtilNFMoney(rsItems(&quot;UNITPRICE&quot;),currencycode)
%>
<td align=&quot;middle&quot;>
<a href=&quot;<%= mscsPage.URL(&quot;item.asp&quot;,&quot;itemno&quot;,ItemNo,&quot;class&quot;,Request.QueryString(&quot;Class&quot;))%>&quot;><img src=&quot;../thumb/<%= trim(ItemNo) %>.jpg&quot; border=&quot;0&quot;></a><br>
<a href=&quot;<%= mscsPage.URL(&quot;item.asp&quot;,&quot;itemno&quot;,ItemNo,&quot;class&quot;,Request.QueryString(&quot;Class&quot;))%>&quot;><%If WebName <> &quot;&quot; Then Response.Write WebName Else Response.Write ItemDescription End If %></a><br>
$<%= UnitPrice %>
<br><br><br>
</td>
<%
If (j Mod 3 = 0) Then Response.Write &quot;</tr>&quot;
rsItems.MoveNext
Loop
Do While Not (j Mod 3 = 0)
Response.Write &quot;<td></td>&quot;
j = j + 1
bRowEnd = True
Loop
If bRowEnd Then Response.Write &quot;</tr>&quot;
%>

</table>
<%
End If

rsItems.Close
Set rsItems = Nothing
%>


Thanks In Advance!
 
is this a field reference or suppose to be referncing a variable?
= '&quot; & MSCSSite.NFSiteName & &quot;' _______________________________________________
[sub]{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924
has you're questio
 
hmm. you're referencing it as a variable value though.
The statement is kind of confusing
your saying here
select NO, DESCRIPTION, WEBNAME, UNITPRICE
from SHOP_ITEM
where the WEBSITECODE field is the value of MSCSSite.NFSiteName field. are those maybe switched in order. or are these values possibly the same in the DB and you really wnat to test for that condition. _______________________________________________
[sub]{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }[/sub]
_______________________________________________
for the best results to your questions: FAQ333-2924
has you're questio
 
This is just a check to ensure that those 2 are of equal value.
 
So MSCSSite is a table in your DB? If so, your SQL statement is invalid because you can't reference a table in the WHERE clause which doesn't appear in the FROM clause.

Maybe you are trying to JOIN the tables?:

Code:
FROM shop_item JOIN mscssite ON shop_item.websitecode = mscssite.nfsitename

Also, do you need to add a wildcard when using LIKE to search for their input?:

Code:
... AND DESCRIPTION LIKE '%&quot; & Request.Form(&quot;searchvalue&quot;) & &quot;%' ...

One more thing, if you are trying to find where parentitem is blank use NULL rather than '':

Code:
... AND PARENTITEM IS NULL ORDER BY ...
--James
 
Bingo!
It was the wildcard. I knew it was something simple. Thanks for your help James! I owe ya one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top