Product Search Codes

2 posts by 2 authors in: Forums > CMS Builder
Last Post: June 9, 2010   (RSS)

Re: [paulmac] Product Search Codes

By Jason - June 9, 2010

Hi,

The best thing to do is to strip out all of the spaces from what the user enters, and strip out all the spaces from the database value being searched against (don't worry, this doesn't permanently change the database value).

First, you need to capture what the client has entered and strip out the spaces. You would use something like this (NOTE:you'll have to change the names to match what you're using):

$productName=str_replace(" ","",@$_REQUEST['productName']);

Next we need to use this value to search against our values in the database:

list($productRecords,$productMetaData)=getRecords(array(
'tableName'=>'products',
'where' => "replace(product_name,\" \",\"\")='".mysql_escape($productName)."'",
'allowSearch => false,
));


This will remove all the blank spaces from the value before performing the search.

Give this a try and let me know how it works for you. If you run into any issues, let me know and attach the .php file you're working with.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/