Howdy,
I am working on a system where I need a basic HTML form to pass data to a cfm page. The cfm page will then query a database and return any matching data. I am using MySQL.
I have my HTML page with a form element that allows a user to enter search criteria. When they click submit it sends the data in the text field to a coldfusion page that runs that data through a query to the database. If a match is found it should display the resulting data. The form works, it sends the complete request to the coldfusion page with no problem. The only problem is that when you enter more than one word, even if both of those words are in the database, it doesn't return any records. I'm wondering if anyone has any ideas on how to fix this, I was thinking of somehow breaking the input string into parts and running each individual part by itself, I'm just not sure how to do that.
Here is the HTML form code.
And here is the query statement:
Any ideas?
I am working on a system where I need a basic HTML form to pass data to a cfm page. The cfm page will then query a database and return any matching data. I am using MySQL.
I have my HTML page with a form element that allows a user to enter search criteria. When they click submit it sends the data in the text field to a coldfusion page that runs that data through a query to the database. If a match is found it should display the resulting data. The form works, it sends the complete request to the coldfusion page with no problem. The only problem is that when you enter more than one word, even if both of those words are in the database, it doesn't return any records. I'm wondering if anyone has any ideas on how to fix this, I was thinking of somehow breaking the input string into parts and running each individual part by itself, I'm just not sure how to do that.
Here is the HTML form code.
Code:
<form method="post" action="../dept_search.cfm"><center> <input name="search" type="text" /> <br /> <input type="submit" value="Department Search" /> </form>
Code:
<cfquery name="search" datasource="dbname"> SELECT * FROM dbtable HAVING name LIKE '%#form.search#%' OR description LIKE '%#form.search#%' OR keywords LIKE '%#form.search#%' </cfquery>
Comment