Computing.Net > Forums > Web Development > search box problem

search box problem

Reply to Message Icon

Original Message
Name: neonwill
Date: January 28, 2008 at 10:35:41 Pacific
Subject: search box problem
OS: xp
CPU/Ram: 512
Model/Manufacturer: hp
Comment:

hi everyone, i have a problem with the software i am currently using accware to maintain my website, and the search box on the website used to be okay. i can put in model number or name and everything to search for the product. but now the search box still works but i have to put exact name for it to find the product(example: product name is "plastic spoon" i have to put in "plastic spoon" to find it, if i put "spoon plastic" then its not gonna find it. anyone know why?

thanx


Report Offensive Message For Removal

Response Number 1
Name: justin.small
Date: January 28, 2008 at 15:48:57 Pacific
Subject: search box problem
Reply: (edit)

are you querying a database? If you're using SQL queries, try this:

Select product_name
From product_table
Where Upper(product_name) like Upper('%form.product_name%')

Justin Small
Owner
Creative Web Solutions, LLC


Report Offensive Follow Up For Removal

Response Number 2
Name: Michael J (by mjdamato)
Date: January 28, 2008 at 22:17:00 Pacific
Subject: search box problem
Reply: (edit)

That would still require the words to be in the same order.

You state it used to work correctly, so my question is "What changed?". Did you do an upgrade, modify the code, what?

Without knowing how your database is constructed it is difficult to give a good answer. The "best" approach would be to use full-text queries. However, the database setup and methods for doing so are beyond a forum for describing. Google for more information.

However, if your database is not set up for full-text searching, then I would suggest the following:

Assuming $input is equal to the search value entered AND assuming you are using PHP you could do one of two things:

1) To find anything that match ANY of the entered words use OR in the implode(), 2) To find anything that match ALL of the entered words use AND in the implode()


$whereValues = explode(' ',$input);
foreach ($whereValues as $key => $value) {
$whereValues[$key] = "value = '%$value%';
}
$whereClause = implode(' OR ', $whereValues);
$query = "SELECT * FROM table WHERE $whereClause";

So using your example above you would get the following query:


SELECT *
FROM table
WHERE value = '%spoon%'
OR value = '%plastic%'

Michael J


Report Offensive Follow Up For Removal

Response Number 3
Name: neonwill
Date: January 29, 2008 at 08:51:06 Pacific
Subject: search box problem
Reply: (edit)

the change is the whole system hang one day and that's when the problem begins.
Accware is the software i use to run my whole store with pos and everything. i can't edit whe website using another software, they already set up the format and everything, when i want to add a product i can just add it in the accware and it will automatically put it to my website. that's why i don't know how to fix it. do i have to fix it in accware or what...(i try to find any function that had to do with search box but nothing found.)

thanx


Report Offensive Follow Up For Removal

Response Number 4
Name: Michael J (by mjdamato)
Date: January 29, 2008 at 14:33:13 Pacific
Subject: search box problem
Reply: (edit)

Well, you should be contacting the vendor. There's no possible way anyone without direct knowledge of that application can give you specific advice on how to fix the problem.

Michael J


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: search box problem

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software