Quote:
Originally Posted by sarettah
Code:
// This assumes that mysql has already been hooked up at the time you construct this
if(isset($_POST['search']))
{
$searchs = array();
if(!empty($_POST['contactname']))
{
// first for protection against sql injection
$contact2use='%' . mysql_real_escape_string($_POST['contactname']) . '%';
// then make a second version to search for
$compressedcontact=str_replace(' ','',$contact2use);
// then look for either version
$searchs[]="contactname LIKE '" . $contact2use . "' or contactname like '" . $compressedcontact . "'";
}
|
If you go this route prior to running the query, you will probably want to replace the space with a wildcard (%) instead to match an either/or situation. Regardless, you will still need to concatenate the database contact names for instances where the POSTed contact name contains no space.