View Single Post
Old 11-13-2012, 02:22 PM  
Tent Pitcher
Confirmed User
 
Tent Pitcher's Avatar
 
Industry Role:
Join Date: Nov 2012
Location: New Orleans
Posts: 213
Quote:
Originally Posted by sarettah View Post
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.
__________________
Tent Pitcher - Adult Search Engine

Last edited by Tent Pitcher; 11-13-2012 at 02:26 PM..
Tent Pitcher is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook