Jump to content

HTML/SQL/ASP Searching a database with user input


Recommended Posts

Hi,I'm trying to create a search form for an online database in order to enable users to search through a list of items.So far I have:<form name="frmSearch" action="foodlist.asp" method="post"><input name="txtSearchItem" type="text"><input type="submit" value="Search"><% Const cs = "..."Dim rsDim txtSearchItemtxtSearchItem = Request.Form("txtSearchItem")Set rs = CreateObject("ADODB.Recordset")rs.Open "SELECT*FROM [Food] WHERE [itemName] LIKE txtSearchItem", csDo Until rs.EOF Response.Write rs.Fields("ItemName").value rs.MoveNextLoopSet rs = Nothing%>I'm pretty sure it's just my syntax on my SQL, I just don't know how to put the variable "txtSearchItem" into the select query.Anyone got any suggestions??ThanksAndy

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...