基于php mysql中的查询链接到特定页面

Well, to begin with, my DB structure is absurd. Still, i need a little help. Somehow, I implemented a table, which takes in input from 4 different tables.

<h2>SEARCH PROTEIN</h2>
            <div class="panel panel-primary">
            <div class="panel-heading">SELECT PROTEIN NAME FROM LIST</div>
            <div class="panel-body">
            <form name="dropdown" action="http://test.php" method="post">
            <select class="form-control" data-style="btn-primary" name="p_ID">
<?php
//provide your hostname, username and dbname
$host="localhost"; 
$username="root";  
$password="";
$db_name="myDB"; 
$con=mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name");

$sql = "select p_ts from protein_search1";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo "<option value=$row[p_ts]>$row[p_ts]</option>";
}

$sql = "select p_ts from protein_search2";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo "<option value=$row[p_ts]>$row[p_ts]</option>";
}

$sql = "select p_ts from protein_search3";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo "<option value=$row[p_ts]>$row[p_ts]</option>";
}

$sql = "select p_ts from protein_search4";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo "<option value=$row[p_ts]>$row[p_ts]</option>";
}
?>

    </select><br><br>
            <button class="btn btn-primary center-block btn-lg" type="submit" >Search</button>
                </form> 

            </div>
        </div>
    </div>

this gives me a dropdown menu, having p_ts id, from all the 4 tables.

now i somehow, want to make a query, that if, the p_ts was found from table1 send it to some page, say 1.php, if found in table2 then to 2.php and so on. here is something that i tried, that is inefficient.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myDB";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error)
    {
      die("Connection failed: " . $conn->connect_error);
    }
else 
{
if(isset($_POST[p_ts]) )
{
if($result->num_rows == 0){
$sql = "select *, '1' as php from protein_search1 where p_ts like '$_POST[p_ts]%'
union
select *, '2' as php from protein_search2 where p_ts like '$_POST[p_ts]%'
union
select *, '3' as php from protein_search3 where p_ts like '$_POST[p_ts]%'
union
select *, '4' as php from protein_search 4where p_ts like '$_POST[p_ts]%' ";
$result = $conn->query($sql) or die($conn->error.__LINE__);
$row=$result->fetch_assoc();
header("Location: ".$row['php'].".php"); }
else 
        {
             echo "0 results";
        }}}

$conn->close();
?>

suggest me some good 'if-else statement' to carry on with this.