Hello,I cant access my two table date together in one search option.like table name: name_search & skill_search.here is the code.please check it and if possible solve it.

    $mysql_db=mysql_select_db('my_database',$connect) or die(mysql_error());

if (isset($_POST['search_name']) && isset($_POST['search_skill']))
 $search_name= $_POST['search_name'];    
 $search_skill= $_POST['search_skill'];
  if(!empty($search_name) && !empty($search_skill)){


  $query = "SELECT name FROM name_search WHERE name LIKE '%".mysql_real_escape_string($search_name)."%'" AND "SELECT skill FROM skill_srch WHERE name LIKE '%".mysql_real_escape_string($search_skill)."%'" ;   // table name: name_search and skill_srch  //
  $query_run= mysql_query($query);


    echo $query_num_rows.' Result Found:<br/>';
 while ($query_row=mysql_fetch_assoc($query_run)){
    echo $query_row['name'].'<br/>';
    echo 'Not found';
     else {
        echo 'Please Character must be more then 5 keywords';

<form action="<?php $current_file; ?> "method="POST">
<input type="test" name="search_name">
<input type="submit" value="search">

Are the two tables somehow related? If yes you can JOIN them and search for both terms. Without knowing the structure of the tables it is hard to tell more.

you can also use UNION but as broj1 said without knowing the structure of your table its hard to tell..geez i just repeat what broj1 said..anyway you can use either of this..

Member Avatar

The UNION structure should see you right:

$search = '%' . mysql_real_escape_string($searchname) . '%';
$result = mysql_query("(SELECT name AS searchout FROM name_search WHERE name LIKE '$search') UNION (SELECT skill AS searchout FROM skill_srch WHERE name LIKE '$search')");

I think. The UNION requires identical fieldnames in both queries.