I figured out the answer, so let me explain it, as well as better explaining the problem. I could see how my original post might not make total sense. The user has texboxes for data like company name, company city, company phone, etc. If they put data only in company name, it only searches based on company name, not city or phone. If they put data into company name and company city, it would search on both of those fields, but not phone. I ended up using the . to build the query variable based on whether a field was set, as such:
$queryString = "SELECT company_id, company_name, company_phone, company_phone_ext, company_email FROM company WHERE";
if (isset($company_city))
{
if ($and_counter == 1)
{
$queryString = $queryString . " AND company_city LIKE '% $company_city%'";
}
if ($and_counter == 0)
{
$queryString = $queryString . " company_city LIKE '%$company_city%'";
$and_counter = 1;
}
}
if (isset($phone_number))
{
if ($and_counter == 1)
{
$queryString = $queryString . " AND company_phone LIKE '%$phone_number%'";
}
if ($and_counter == 0)
{
$queryString = $queryString . " company_phone LIKE '%$phone_number%'";
$and_counter = 1;
}
}
$queryString = $queryString . "ORDER BY company_name;";
So forth and so on for all of the variables.
Aaron