I am new to using fulltext search and union for mysql and php. I want to check if the results found came from the advert table and if so fetch results else from members table. it doesnt seem to be working for me because im getting no results even though i have the them in my database tables. can anyone help me please. Im stuck? here is my code i have done so far.
ini_set('display_errors', '1');
$search_output = "";
if(isset($_POST['searchquery']) && $_POST['searchquery'] != ""){
	$searchquery = preg_replace('#[^a-z 0-9?!]#i', '', $_POST['searchquery']);
		include ('config/config.php');	
		$sqlCommand = "(SELECT * FROM advert WHERE MATCH (header,ad_text) AGAINST ('$searchquery')) UNION (SELECT * FROM members WHERE MATCH (company,aboutus) AGAINST ('$searchquery'))";
    $query = mysql_query($sqlCommand) or die(mysql_error());
	$count = mysql_num_rows($query);
	if($count > 1){
		$search_output .= "<hr />$count results for <strong>$searchquery</strong>";
		$row = mysql_fetch_array($query);
		if(isset($row['header']) OR isset($row['ad_text'])) {
			echo "Advert";
			while($rows = mysql_fetch_array($query)){
				$header = $rows["header"];
				$ad_text = $rows["ad_text"];
				$search_output .= "Item ID: $header - $ad_text<br />";
			} // close while
		elseif(isset($row['company']) OR isset($row['aboutus'])) {
			echo "Business";
			while($rows = mysql_fetch_array($query)){
				$company = $rows["company"];
				$aboutus = $rows["aboutus"];
				$search_output .= "Item ID: $company - $aboutus<br />";
			} // close while
		else {
		$search_output = "<hr />0 results for <strong>$searchquery</strong><hr />$sqlCommand";
<h2>Search the Exercise Tables</h2>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Search For: 
  <input name="searchquery" type="text" size="44" maxlength="88"> 
<input name="myBtn" type="submit">
<br />
<?php echo $search_output; ?>