|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
simple search of mysql database
i have a mysql table containing two fields: id and colour and i want to search for colours with a simple text entry search box.
This is the html: <form action='search.asp' method=""> <td align="left" bgcolor="#FFFFFF"> <input class="formcreate" type="text" name='txtKeyWord' size="20"> <input class="formcreate" type="submit" value="GO" name="search"> </td> </form> This is search.asp <%@ LANGUAGE="VBSCRIPT" %> <% strConnection = "driver={MySQL};server=localhost;uid=manxpharmacy;pwd=medicine;database=rangeexchange" Set adoDataConn = Server.CreateObject("ADODB.Connection") adoDataConn.Open strConnection %> <% strQuery = "SELECT * FROM selling WHERE colour LIKE 'txtKeyWord'" Set Data = adoDataConn.Execute(strQuery) If Not Data.BOF Then %> <html><TABLE><TR><TD><b>id</b></TD><TD><b>Colour</b></TD></TR> <% Do While Not Data.EOF %> <TR><TD><%=Data("id").Value %></TD><TD><%=Data("colour").Value %></TD></TR> <% Data.MoveNext Loop %> </TABLE> <% Else Response.Write("Sorry, no data found.") End If %> <% Data.Close adoDataConn.Close Set adoDataConn = Nothing Set Data = Nothing %> The search isn't producing any results - the problem must be with the 'txtKeyWord' submission from the form into search.asp. Please help! |
|
#2
|
|||
|
|||
|
Pardon me for my ignorance. But I thought the following is required?
Code:
txtKeyword = Trim(Request("txtKeyword"))
txtKeyword = Replace(txtKeyword,"'","")
I would also suggest that the search term shouldnt be specific. Change the sql to ".....LIKE '%txtKeyword%'..." |
|
#3
|
|||
|
|||
|
Your ignorance is pardoned since mine is greater! Please could you explain your suggestion?
|
|
#4
|
|||
|
|||
|
From what i see, you did not specify where the value of 'txtKeyWord' comes from. Hence, in your search.asp, 'txtKeyWord' is actually an empty value.
Or did i miss out anything? |
|
#5
|
|||
|
|||
|
'txtKeyWord' is posted in the form html. Does it need to called into the asp?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > simple search of mysql database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|