Mysql在两个表中搜索

I have a table name tbl_marketing contain many column

db_id,db_customer,db_brand,db_client....

Another table name tbl_phonecall contain many column and linked with tbl_marketing in db_mid this contain the id of tbl_marketing

db_id,db_subject,db_due,db_nextdate,db_mid

know i create a search form this search form should do a search on all field on tbl_marketing and on db_due and db_nextdate in tbl_phonecall when the user do his search the result should like this

Customer brand client due nextdate the customer brand and client from tbl_marketing and the rest from tbl_phonecall

for that search i use this php code

$q = array();  
    $sql = "";
     if(isset($_POST['txt_name']) && !empty($_POST['txt_name'])){  
    $name = mysqli_real_escape_string($conn,$_POST['txt_name']); 
    $q[] = "tbl_marketing.db_customer='".$name."' ";      
    }
    if(isset($_POST['txt_client']) && !empty($_POST['txt_client'])){  
    $client = mysqli_real_escape_string($conn,$_POST['txt_client']); 
    $q[] = "tbl_marketing.db_client='".$client."' ";      
    }
    if(isset($_POST['txt_brand']) && !empty($_POST['txt_brand'])){  
    $brand = mysqli_real_escape_string($conn,$_POST['txt_brand']); 
    $q[] = "tbl_marketing.db_brand='".$brand."' ";      
    }
    if(isset($_POST['txt_dateofcalling']) && !empty($_POST['txt_dateofcalling'])){  
    $dateofcalling= mysqli_real_escape_string($conn,$_POST['txt_dateofcalling']);
    $searchdateofcalling=date("Y-m-d H:i:s", strtotime($dateofcalling));    
    $q[] = "DATE(tbl_phonecall.db_due)='".$searchdateofcalling."' ";      
    }
     if(isset($_POST['txt_nextdate']) && !empty($_POST['txt_nextdate'])){  
    $nextdate= mysqli_real_escape_string($conn,$_POST['txt_nextdate']);
    $searchnextdate=date("Y-m-d H:i:s", strtotime($nextdate));       
    $q[] = "DATE(tbl_phonecall.db_nextdate)='".$searchnextdate."' ";      
    }
    $first = true; 
    foreach($q as $qu){  
        if($first){  
        $sql .= " where ".$qu;      
        $first = false;  
        }else{  
        $sql .= " and ".$qu;          
        } 
    } 
$query=mysqli_query($conn,"select tbl_marketing.*,tbl_phonecall.* from tbl_marketing,tbl_phonecall {$sql}")or die(mysqli_error($conn));

but this query repeat the value

How can i solve that problem and have a result like i post before

Looks like you have missed the join condition

where tbl_marketing.db_id = tbl_phonecall.db_mid

In case you want to return records from tbl_marketing even if no matching records exist in tbl_phonecall table, use left join in your query

select tbl_marketing.*,tbl_phonecall.* 
from tbl_marketing left join tbl_phonecall 
on tbl_marketing.id = tbl_phonecall.mid 
where ....<<where conditions here>>