no no no ... Sorry Diego, it's not your code that wasn't working. The problem was due to $sqlquery itself. I fixed the problem a few hours ago and now I have to go back to all the forums and post the solution I found (thanks to other webmaster's help, you included).
Let me explain. This is what I had before:
if ( $baddress != "" && $baddress != " " ) $mbaddress = "(baddress LIKE '%$baddress%')";
if ( $bcity != "" && $bcity != " " ) $mbcity = "(bcity LIKE '%$bcity%')";
if ( $bpostcode != "" && $bpostcode != " " ) $mbpostcode = "(bpostcode LIKE '%$bpostcode%')";
if ( $bstate != "" && $bstate != " " ) $mbstate = "(bstate LIKE '%$bstate%')";
if ( $bcountry != "" ) $mbcountry = "(bcountry LIKE '%$bcountry%')";
$sqlquery = "$mbaddress $mbcity $mbpostcode $mbstate $mbcountry";
if ($boolean == "OR") $sqlquery = str_replace (') (',') OR (', $sqlquery);
if ($boolean == "AND") $sqlquery = str_replace (') (',') AND (', $sqlquery);
mysql_select_db( $dbprofiles );
$result = mysql_query("SELECT * FROM myadd WHERE ($sqlquery) ORDER BY bname ASC, ownership ASC") or error( mysql_error() );
So I changed:
$sqlquery = "$mbaddress $mbcity $mbpostcode $mbstate $mbcountry";
if ($boolean == "OR") $sqlquery = str_replace (') (',') OR (', $sqlquery);
if ($boolean == "AND") $sqlquery = str_replace (') (',') AND (', $sqlquery);
To:
$sqlquery = "$mbname"."$mownership"."$mindustry"."$mbusman"."$mbusret"."$mbusimp"."$mbuscont"."$mbusdis"."$mbuscons"."$mbuswho"."$mbusbuy"."$mbusdea"."$mbusoth"."$mbaddress"."$mbcity"."$mbpostcode"."$mbstate"."$mbcountry";
if ($boolean == "OR") $sqlquery = str_replace (")(",") $boolean (", $sqlquery);
if ($boolean == "AND") $sqlquery = str_replace (")(",") $boolean (", $sqlquery);
And now it works like a charm... 😃 Thank you Diego and LordShryku. Great forum also.